[Haskell-cafe] Why were unfailable patterns removed and "fail" added to Monad?

Gregory Crosswhite gcrosswhite at gmail.com
Fri Jan 20 04:43:33 CET 2012


On 01/20/12 13:23, Edward Z. Yang wrote:
>     In Haskell 1.4 g would not be in MonadZero because (a,b) is unfailable
>     (it can't fail to match).  But the Haskell 1.4 story is unattractive becuase
>             a) we have to introduce the (new) concept of unfailable
>             b) if you add an extra constructor to a single-constructor type
>                then pattern matches on the original constructor suddenly become
>                failable
>
> (b) is a real killer: suppose that you want to add a new constructor and
> fix all of the places where you assumed there was only one constructor.
> The compiler needs to emit warnings in this case, and not silently transform
> these into failable patterns handled by MonadZero...

Okay, great, that explains two things that had not been clear to me: 
first, that the notion of "unfailable" was not removed from the language
so much as not added in the first place, and second, that if
"unfailable" *had* been added to the language then this would have
created the serious risk that adding a new constructor to a type could
change the meaning of your code by changing formerly irrefutable pattern
matches into potential sources of mzeros.

Thanks!
Greg




More information about the Haskell-Cafe mailing list