[Haskell-cafe] trying to understand monad transformers....

Magnus Therning magnus at therning.org
Tue Sep 9 03:05:16 EDT 2008

2008/9/9 Daryoush Mehrtash <dmehrtash at gmail.com>:
> The MaybeT transformer is defined as:
> newtype MaybeT m a = MaybeT {runMaybeT :: m (Maybe a)}
> instance Functor m => Functor (MaybeT m) where
>   fmap f x = MaybeT $ fmap (fmap f) $ runMaybeT x
> ....
> Question:  What does "runMaybeT x" mean?

If you mean "what does it do?" then the answer is that it unwraps the
MaybeT so that you can get to the inner value.  If you mean "how does
it do it?" then I believe the best thing is to read some of the
chapters in RWH because I think I recognise a rather common
Haskell-pattern here.  I don't remember which ones, but I'm sure
others on this list have better memory than I do ;-)

If this isn't what you were looking for, then I haven't understood the
question :-)


More information about the Haskell-Cafe mailing list