Generalize MonadIO to MonadBase

John Lato jwlato at gmail.com
Tue Apr 20 13:26:11 EDT 2010


> From: Bas van Dijk <v.dijk.bas at gmail.com>
>
> Hello,
>
> (This should actually be a reply to the "Move MonadIO to base"
> thread[1] but I didn't want to break up the extremely interesting
> discussion on the MonadTransMorph class)
>
> Would it be useful if we got rid of MonadIO:
>
> class (Monad m) => MonadIO m where liftIO :: IO a -> m a
>
> and replace it with the generalization:
>
> class (Monad m, Monad n) => MonadBase m n | m -> n where inBase :: n a -> m a
>
> which would allow lifting not just IO but any base monad into a stack
> of monad transformers.
>

I personally wouldn't find this particularly useful.  Nearly all of my
monadic programming (i.e. everything that comes to mind) uses one of
three types of monads:
1.  IO
2.  ST
3.  Monad transformers stacked on IO

Lifting functions are only useful in the third case, and then I only
need "lift" and "liftIO".  I do like the idea and I'm not opposed to
the suggestion, I just don't see a use for it myself.

John


More information about the Libraries mailing list