Should exhaustiveness testing be on by default?

Lennart Augustsson lennart at augustsson.net
Tue May 19 07:18:08 EDT 2009


Excellent, is there a -fuse-catch flag for ghc? :)

On Tue, May 19, 2009 at 12:01 PM, Neil Mitchell <ndmitchell at gmail.com> wrote:
>>  > ... 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.
>
> Thanks
>
> Neil
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>


More information about the Glasgow-haskell-users mailing list