
Any refutable pattern match in do would force MonadFail (or MonadPlus if you
prefer). So
1. (MonadFail m) => a -> m a, \ a -> return a
2. (MonadFail m) => m a, mfail "..."
3. (MonadFail m) => Maybe a -> m a, \ a -> case a of Nothing -> mfail
"..."; Just x -> return x
4. (Monad m) => a -> b -> m a, \ a b -> return a
5. (Monad m) => (a, b) -> m a, \ (a, b) -> return a
As far as type inference and desugaring goes, it seems very little would
have to be changed in an implementation.
-- Lennart
2010/12/15 Tillmann Rendel
Hi John,
John Smith wrote:
Perhaps pattern match failures in a MonadPlus should bind to mzero - I believe that this is what your example and similar wish to achieve.
You updated the proposal to say:
a failed pattern match should error in the same way as is does for pure code, while in MonadPlus, the current behaviour could be maintained with mzero
Can you be more specific as to how that would interact with polymorphism and type inference? What does it mean to be "in MonadPlus"? How does the compiler know?
For example, what would be the static types and dynamic semantics of the following expressions:
1. \a -> do {Just x <- return (Just a); return x}
2. do {Just x <- return Nothing; return x}
3. \a -> do {Just x <- a; return x}
4. \a b -> do {(x, _) <- return (a, b); return x}
5. \a -> do {(x, _) <- return a; return x}
Tillmann
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe