Can I selectively delete the `ghc-options` .cabal file in specific files?
I use
ghc-options: -Wall
in my .cabal file and love it ....
.... except when I hate him. For example, I have a file Constants.hs
that looks like
numDogs=1000 numCats=2000 ...... ....etc for like 100 lines
.... and of course -Wall
complains that I don't pass all my signature types but change the file to this
numDogs::Int
numDogs=1000
numCats::Int
numCats=2000
....etc
really would be stupid.
So, is there a way to disable ghc-opts for each file.
(I know I can just exclude the ghc options from cabal and put it in every file I want to use when using {-# OPTIONS_GHC -Wall #-}
, but when I do that I often forget the files altogether, d rather not do it this way)
source to share
Well, {-# OPTIONS_GHC flag #-}
can take any GHC flag , so you can just use -w
to disable all warnings. But since you are mainly concerned about missing signatures for constants, you probably want -fno-warn-missing-signatures
both -fno-warn-type-defaults
:
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
That being said, if you are using a bunch of constants with one type, you can simply write:
numDogs, numCats, numParrots, numFishes, numRats :: Int
This also removes the warning and ensures the constants are of the correct type.
source to share
Most of the -Wall
default flags have an inverse parameter -f-no-*
that, if applied locally, will override the global setting. So, for example, in a module that you don't want to have level signatures, you can add:
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
And this will still give your module all the other checks implied by -Wall (incomplete templates and whatnot), but just not missing signatures.
source to share