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

James Cook mokus at deepbondi.net
Fri Jan 20 13:30:41 CET 2012


Actually, that's not what this conversation is about - it's about what to with those types of bindings instead of the way 1.4 had been doing it.

On Jan 19, 2012, at 10:19 PM, Edward Z. Yang wrote:

> Hello Gregory,
> 
> The original (1998!) conversation can be found here:
> 
>    http://www.mail-archive.com/haskell@haskell.org/msg03002.html
> 
> I think Simon Peyton-Jones' example really sums up the whole issue:
> 
>    But [MonadZero] really sticks in my craw.  How can we explain this:
> 


[MonadZero] is not the correct summary here.  "(1)" refers to the proposal of replacing the "failable" with "refutable" in the semantics, which leads to the weird example he then gives.


>            f :: Monad m => m (a,b) -> m a
>            f m1 = do { x <- m1; return (fst x) }
> 
>            g :: MonadZero m => m (a,b) -> m a
>            g m1 = do { (a,b) <- m1; return a }
> 
>            h :: Monad m => m (a,b) -> m a
>            h m1 = do { ~(a,b) <- m1; return a }
> 
>    Why must g be in MonadZero?  Because the pattern (a,b) is refutable (by
>    bottom).
> 

Again, this is the situation under a proposal where MonadZero is still inferred for some bindings, as in 1.4, but not for "unfailable" ones as 1.4 would have specified - for "refutable" ones.  All of those would count as unfailable under 1.4 and so none would require MonadZero.

-- James


More information about the Haskell-Cafe mailing list