Should exhaustiveness testing be on by default?

Neil Mitchell ndmitchell at
Mon May 18 04:38:00 EDT 2009

I'm not a particular fan of exhaustiveness checking. It just
encourages people to write:

foo (Just 1) [x:xs] = important case
foo _ _ = error "doh!"

So now when the program crashes, instead of getting a precise and
guaranteed correct error message, I get "doh!" - not particularly
helpful for debugging.

I think it's not that useful for writing personal code, but for
writing production code (which you're going to ship off) it's probably
important that you cover all cases. However, for that it would be much
better to use a tool such as Catch
(, which actually guarantees
you won't crash, rather than a simple syntactic check. As such, I
think it's perfect to be included in a set of warnings, but not great
to be a default. I also think that if we change our policies every
time someone writes a critical blog we'll be going round in circles

I'm also not a fan of the overlapping patterns warning being on by
default, as I often write:

foo (Case1 x y z) = ...
foo (Bar x) = ...
foo x = error $ show ("Unhandled in foo",x)

This is overlapping, and for a very good reason.



On Mon, May 18, 2009 at 2:18 AM, Lennart Augustsson
<lennart at> wrote:
> The exhaustiveness checker in ghc is not good.  It reports
> non-exhaustive matching a bit too often and also the error messages
> are often not in terms of the original source but some desugared
> version.
> If those things were improved I think it should be always on.
> On Mon, May 18, 2009 at 12:53 AM, Don Stewart <dons at> wrote:
>> I'm not sure I'd want -Wall on by default (though being -Wall clean is
>> very good). But exhaustive pattern checking might well help out a lot of
>> people coming from untyped backgrounds.
>> Ron's also wondering why exhaustive pattern checking isn't on ?
>> Anyone know why it isn't the default?
>> -- Don
>> _______________________________________________
>> Glasgow-haskell-users mailing list
>> Glasgow-haskell-users at
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list