I'm using GHC on haskell-stack project. I'd like to lift missing-fields warning up to a compile error.
I tried to do the following, but it doesn't work.
{-# OPTIONS_GHC -Werror=missing-fields #-} -- DOESN'T WORK
Could you tell how to lift missing fields warning up to a compile error?
This only works in GHC 8.2.1 and above. If you're using stack
, the current LTS resolver is only on 8.0.2. Either update your GHC (in stack
, that would be setting compiler: ghc-8.2.1
), or just make all warnings into errors with -Werror -Wmissing-fields
, and sit tight until the feature is more widely available. (If you trigger another warning, say missing-methods
, it stays a warning in the former, but becomes an error in the latter.)
Just make fields strict. This is a good practice in general because it helps to avoid space leaks and can lead to other optimizations. In case you don't really rely on laziness, you can convert fields to strict.
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