Any refutable pattern match in do would force MonadFail (or MonadPlus if you prefer). So<div>1. (MonadFail m) => a -> m a, \ a -> return a</div><div>2. (MonadFail m) => m a, mfail "..."</div><div>
3. (MonadFail m) => Maybe a -> m a, \ a -> case a of Nothing -> mfail "..."; Just x -> return x</div><div>4. (Monad m) => a -> b -> m a, \ a b -> return a</div><div>5. (Monad m) => (a, b) -> m a, \ (a, b) -> return a</div>
<div><br></div><div>As far as type inference and desugaring goes, it seems very little would have to be changed in an implementation.</div><div><br></div><div> -- Lennart</div><div><br><div class="gmail_quote">2010/12/15 Tillmann Rendel <span dir="ltr"><<a href="mailto:rendel@informatik.uni-marburg.de">rendel@informatik.uni-marburg.de</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi John,<div class="im"><br>
<br>
John Smith wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Perhaps pattern match failures in a MonadPlus should bind to mzero - I<br>
believe that this is what your example and similar wish to achieve.<br>
</blockquote>
<br></div>
You updated the proposal to say:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
a failed pattern match should error in the same way as is does for pure code, while in<br>
MonadPlus, the current behaviour could be maintained with mzero<br>
</blockquote>
<br>
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?<br>
<br>
For example, what would be the static types and dynamic semantics of the following expressions:<br>
<br>
1. \a -> do {Just x <- return (Just a); return x}<br>
<br>
2. do {Just x <- return Nothing; return x}<br>
<br>
3. \a -> do {Just x <- a; return x}<br>
<br>
4. \a b -> do {(x, _) <- return (a, b); return x}<br>
<br>
5. \a -> do {(x, _) <- return a; return x}<br><font color="#888888">
<br>
Tillmann</font><div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>