Why GHC doesn't warn about LHS nullary-constructor pattern bindings?

Herbert Valerio Riedel hvr at gnu.org
Thu Jul 19 12:50:02 CEST 2012


Recently, I was a bit suprised that GHC didn't warn about useless
`where` definitions such as the following when using `-Wall` (and I
couldn't find a respective warning GHC CLI flag which would have enabled
reporting a warning in this case -- unless I missed it)

  module Foo where
  foo :: Int -> Int
  foo n = n + 1
      Nothing = Just n

...wouldn't it be a sensible thing for GHC to warn in such cases
(i.e. when the LHS of a pattern binding is a nullary constructor), or is
there a useful application for this construct?

(In my original case, I ended up with such a "dead" construct after some
"unsound" code refactoring, and it would have helped me catch my error
earlier, if GHC would have pointed out that somethings fishy with my

More information about the Glasgow-haskell-users mailing list