[Haskell-cafe] More death to partial functions: Should -fwarn-incomplete-uni-patterns be enabled with -Wall?

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sun Nov 8 09:30:09 UTC 2015


On Sun, Nov 08, 2015 at 09:36:13AM +0100, Joachim Breitner wrote:
> Am Sonntag, den 08.11.2015, 01:10 +0100 schrieb Niklas Hambüchen:
> > In an older mail from 2010
> > (https://mail.haskell.org/pipermail/glasgow-haskell-users/2010-Septem
> > ber/019237.html)
> > I saw Simon mention that it wasn't planned to warn about inexhaustive
> > patterns like this.
> 
> note that in that mail, he refers to patterns in where clauses, which
> is a different use-case than the lambdas you refer to.
>
[...]
> 
> Then you are in a good position to argue that it is an improvement (or
> you will find that SPJ, as very often, has a good instinct and making
> it warn about that prohibits many useful idioms.)

Simon's code is inadvisable, in my opinion.  It is

    f xs | null xs = blah
         | otherwise = x+1
         where
           (x:_) = xs

where it really should be

    f xs = case xs of []    -> blah
                      (x:_) -> x + 1

Tom


More information about the Haskell-Cafe mailing list