Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to remove warning "Instead of 'ghc-options: -XOverloadedStrings ..." #6589

Open
diqye opened this issue May 21, 2024 · 6 comments
Open

Comments

@diqye
Copy link

diqye commented May 21, 2024

package.yaml

...
ghc-options:
- -Wall
- -fno-warn-missing-signatures
- -fno-warn-type-defaults
- -fno-warn-name-shadowing
- -fno-warn-orphans
- -fno-warn-incomplete-uni-patterns
- -fno-warn-unused-top-binds
- -fno-warn-unused-imports
- -XExtendedDefaultRules
- -XOverloadedStrings
- -XFlexibleContexts
- -XConstraintKinds
- -XScopedTypeVariables
- -XTemplateHaskell
...

There are some warning as bellow when i run stack repl

~/p/runai (master|✚4) $ stack repl
Using main module:
1.  Package runai, component runai:exe:runai, with main-is file:
    /Users/diqye/projects/runai/app/Main.hs.

myai > initial-build-steps (lib)
runai> configure (lib + exe)
runai> Configuring runai-0.1.0.0...
runai> Warning: Instead of 'ghc-options: -XExtendedDefaultRules -XOverloadedStrings
runai> -XFlexibleContexts -XConstraintKinds -XScopedTypeVariables -XTemplateHaskell
runai> -XExtendedDefaultRules -XOverloadedStrings -XFlexibleContexts
runai> -XConstraintKinds -XScopedTypeVariables -XTemplateHaskell' use 'extensions:
runai> ExtendedDefaultRules OverloadedStrings FlexibleContexts ConstraintKinds
runai> ScopedTypeVariables TemplateHaskell ExtendedDefaultRules OverloadedStrings
runai> FlexibleContexts ConstraintKinds ScopedTypeVariables TemplateHaskell'
runai> initial-build-steps (lib + exe)

Except : No warning

@diqye
Copy link
Author

diqye commented May 21, 2024

I think this is a warning generated when Stack generates Cabel file without using 'ghc-options', and then runs cabal

@mpilgrem
Copy link
Member

@diqye, I suspect that is a message from Cabal (the library). If you stack build with Cabal set to be less verbose (https://docs.haskellstack.org/en/stable/build_command/#-no-cabal-verbosity-option) does the warning disappear?

@mpilgrem
Copy link
Member

mpilgrem commented May 21, 2024

@diqye, I don't know why you are getting advice from Cabal (the library) to use extensions: - it was deprecated in Cabal 1.12 and removed in Cabal (EDIT) package description format 3.0: https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html#pkg-field-extensions. What version of GHC are you specifying with stack repl?

EDIT: Hpack supports default-extensions: https://github.com/sol/hpack?tab=readme-ov-file#common-fields.

@diqye
Copy link
Author

diqye commented May 22, 2024

@mpilgrem

~/p/runai (master|✚4) $ ls $(stack path --compiler-bin)
ghc@               ghci@              hp2ps@             hsc2hs@            runhaskell@
ghc-9.4.7*         ghci-9.4.7*        hp2ps-ghc-9.4.7*   hsc2hs-ghc-9.4.7*  runhaskell-9.4.7*
ghc-pkg@           haddock@           hpc@               runghc@
ghc-pkg-9.4.7*     haddock-ghc-9.4.7* hpc-ghc-9.4.7*     runghc-9.4.7*

I just reproduced this problem

  1. Delete cabal file (eg. runai.cabal)
  2. Run commoand stack build
~/p/runai (master|✚4) [SIGINT]$ stack build --cabal-verbose
runai> configure (lib + exe)
runai> Using Parsec parser
runai> Configuring runai-0.1.0.0...
runai> Warning: Instead of 'ghc-options: -XExtendedDefaultRules -XOverloadedStrings
runai> -XFlexibleContexts -XConstraintKinds -XScopedTypeVariables -XTemplateHaskell
runai> -XExtendedDefaultRules -XOverloadedStrings -XFlexibleContexts
runai> -XConstraintKinds -XScopedTypeVariables -XTemplateHaskell' use 'extensions:
runai> ExtendedDefaultRules OverloadedStrings FlexibleContexts ConstraintKinds
runai> ScopedTypeVariables TemplateHaskell ExtendedDefaultRules OverloadedStrings
runai> FlexibleContexts ConstraintKinds ScopedTypeVariables TemplateHaskell'

This warning will appear whether flg is added or not.

@diqye
Copy link
Author

diqye commented May 22, 2024

If you do not delete the cabal file, this warning will not appear.

@mpilgrem
Copy link
Member

After a little experimentation, this is indeed a Cabal (the library) warning. (Stack uses Cabal to build; by default, Stack builds when you command stack repl - see https://docs.haskellstack.org/en/stable/ghci/.) The easiest way to avoid the warning is to follow Cabal's advice, except the advice is not complete (which could be characterised as an existing Cabal bug): if you use extensions: in your Cabal file, Cabal will then warn you that it is deprecated in favour of default-extensions (which field is also supported by Hpack in its package.yaml format).

Another way to avoid the warning is to set --cabal-verbosity silent - however, that will also silence all other Cabal output. With stack repl you can, in fact, command stack --cabal-verbosity silent repl because all stack build flags/options are actually (hidden) global options.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants