MonadFail proposal (MFP): Moving fail out of Monad

David Feuer david.feuer at gmail.com
Wed Jun 10 14:19:05 UTC 2015


Here's a crazy question: would a version of MonadError without the
fundep do the trick?

class Monad m => MonadFail e m where
  fail :: e -> m a

instance MonadFail a [] where
  fail = const []

instance (a ~ e) => MonadFail e (Either a) where
  fail = Left

instance MonadFail SomeException IO where
  fail = throwIO
instance MonadFail IOException IO where
  fail = throwIO
...
instance MonadFail String IO where
  fail = throwIO . userError

On Wed, Jun 10, 2015 at 8:32 AM, Mario Blažević <blamario at ciktel.net> wrote:
> +1 from me.
>
>     A minor nitpick: the proposal should clarify which of the existing
> instances of Monad from base get a MonadFail instance. My understanding is
> that none of them would define fail = error, but that has not been made
> explicit.
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list