I am using
ghc-options: -Wall
in my .cabal file, and love it....
....except when I hate it. For instance, I have a Constants.hs file that looks like this
numDogs=1000
numCats=2000
......
....etc for like 100 lines
....and of course -Wall complains that I don't give all my types signatures, but changing the file to this
numDogs::Int
numDogs=1000
numCats::Int
numCats=2000
....etc
really would be stupid.
So, is there a way to turn off ghc-opts on a per file basis.
(I know that I can just leave out the ghc-options from cabal, and put it in each file that I want it in using {-# OPTIONS_GHC -Wall #-}, but when I do that, I often forget files altogether, so I'd rather not do it this way)
Well, {-# OPTIONS_GHC flag #-} can take any GHC flag, so you can simply use -w to disable all warnings. But since you're mostly concerned about the missing signatures for constants, you probably want -fno-warn-missing-signatures and -fno-warn-type-defaults:
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
That being said, if you're using a bunch of constants with the same type, you can simply write:
numDogs, numCats, numParrots, numFishes, numRats :: Int
That also removes the warning, and makes sure that the constants have the appropriate type.
Most of the flags implied by -Wall have an inversion -f-no-* option that if you apply locally will override the global setting. So for instance in a module that you want not to have toplevel signature you could add:
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
And this will still endow your module with all the other checks implied by -Wall ( incomplete patterns and whatnot ) but just not missing signatures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With