[Haskell-cafe] Best idiom for avoiding Defaulting warnings with ghc -Wall -Werror ??

Henning Thielemann lemming at henning-thielemann.de
Fri Jun 22 18:29:27 EDT 2007

On Fri, 22 Jun 2007, Brandon S. Allbery KF8NH wrote:

> I have a program which I'm checking with -Wall but not -Werror,
> because it has several pattern matches which *I* know are fine but
> which ghc doesn't.  (I suspect, from its description, that Catch
> would also recognize it's fine.)  Which leads me to wonder:
> (1) any way to flag a pattern match as "I know this is okay", don't
> warn about it" without shutting off pattern match warnings completely?

Add the "catch all" case with '_':

f _ = error "this case cannot occur, because this would violate the invariant X"

If the error occurs anyway, you get a report that your believe was wrong.
(Or the user gets the report, and he doesn't know how to react.)

More information about the Haskell-Cafe mailing list