Should exhaustiveness testing be on by default?

Neil Mitchell ndmitchell at
Tue May 19 07:01:59 EDT 2009

>  > ... exhaustive pattern checking might well help out a lot of
>  > people coming from untyped backgrounds...
> Or even people from typed backgrounds.  I worship at the altar of
> exhaustiveness checking.

Do you really want exhaustiveness, or is what you actually want safety?

With -fwarn-incomplete-patterns:

test1 = head []

test2 = x where (x:xs) = []

test3 = (\(x:xs) -> 1) []

test4 = f [] where f [] = 1

GHC reports that test4 has incomplete patterns, but the others don't.
However, test4 is safe, but the others aren't. Exhaustiveness is a
poor approximation of safety. GHC's exhaustiveness checker is a poor
approximation of exhaustiveness. 2 is a poor approximation of pi :-)

Using Catch, it reports that test1..3 were faulty, but test4 is safe.



More information about the Glasgow-haskell-users mailing list