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

Luminous Fennell mstrlu at gmx.net
Fri Jan 20 08:15:41 CET 2012


On Fri, Jan 20 2012 at 06:22 +0100, Evan Laforge wrote:

> On Thu, Jan 19, 2012 at 8:53 PM, Edward Z. Yang <ezyang at mit.edu> wrote:
>> It's not obvious that this should be turned on by -Wall, since
>> you would also trigger errors on uses like:
>>
>>   [ x | Just x <- xs ]

> [...]
>  I would have suggested that listcomp
> match failures yield [] but monad ones be errors, but now that list
> comps and monads are back together again maybe that's not so easy to
> do...
>

Perhaps a generalization of this would be to warn only if fail was
inherited by the original Monad typeclass, where it seems obvious that
fail takes the role of a ``work-around''. When fail is overwritten one
could perhaps assume that calling it is the intended behavior for
pattern match failures.

Lu



More information about the Haskell-Cafe mailing list