<div dir="ltr">This would require you to add MPTCs to the language standard, which means standardizing how they work.<div><br></div><div>Any solution involving SomeException or any of its variants is going to drag in GADTs, Typeable, higher rank types.</div><div><br></div><div>... and it would drag them inexorably into the Prelude, not just base.</div><div><br></div><div>Compared to a simple</div><div><br></div><div><font face="monospace, monospace">class Monad m => MonadFail m where</font></div><div><font face="monospace, monospace">  fail :: String -> m a</font></div><div><br></div><div>that is a very hard sell!</div><div><br></div><div>On the other hand, I do think what we could do is add more information about pattern match failures by adding another member to the class</div><div><br></div><div><font face="monospace, monospace">class Monad m => MonadFail m where</font></div><div><font face="monospace, monospace">  patternMatchFailure :: Location -> String -> whatever else you like -> m a</font></div><div><font face="monospace, monospace">  patternMatchFailure l s ... = fail (code to generate the string we generate in the compiler using just the parts we're passed)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  fail :: String -> m a</font></div><div><br></div><div>Then the existing 'fail' desugaring could be done in terms of this additional member and its default implementation.</div><div><br></div><div>This remains entirely in the "small" subset of Haskell that is well behaved. It doesn't change if we go and radically redefine the way the exception hierarchy works, and it doesn't require a ton of standardization effort.</div><div><br></div><div>Now if we want to make the fail instance for IO or other MonadThrow instances package up the patternMatchFailure and throw it in an exception we have the freedom, but we're avoid locking ourselves in to actually trying to figure out how to standardize all of the particulars of the exception machinery into the language standard.</div><div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 10, 2015 at 4:19 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here's a crazy question: would a version of MonadError without the<br>
fundep do the trick?<br>
<br>
class Monad m => MonadFail e m where<br>
  fail :: e -> m a<br>
<br>
instance MonadFail a [] where<br>
  fail = const []<br>
<br>
instance (a ~ e) => MonadFail e (Either a) where<br>
  fail = Left<br>
<br>
instance MonadFail SomeException IO where<br>
  fail = throwIO<br>
instance MonadFail IOException IO where<br>
  fail = throwIO<br>
...<br>
instance MonadFail String IO where<br>
  fail = throwIO . userError<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Jun 10, 2015 at 8:32 AM, Mario Blažević <<a href="mailto:blamario@ciktel.net">blamario@ciktel.net</a>> wrote:<br>
> +1 from me.<br>
><br>
>     A minor nitpick: the proposal should clarify which of the existing<br>
> instances of Monad from base get a MonadFail instance. My understanding is<br>
> that none of them would define fail = error, but that has not been made<br>
> explicit.<br>
><br>
><br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>