MaybeT to transformers

Sittampalam, Ganesh ganesh.sittampalam at
Fri Feb 6 11:56:27 EST 2009

Henning Thielemann wrote:
> Sittampalam, Ganesh wrote:
>> Henning Thielemann wrote:
>>> What about adding the Maybe monad transformer as provided in MaybeT
>>> package to the transformers package?
>>> The module name could be
>>>    Control.Monad.Trans.Maybe
>>>   which would also avoid conflicts with the MaybeT package.
>> What MonadPlus instance will it get, if any?
> The one which is currently used by MaybeT:
> instance (Monad m) => MonadPlus (MaybeT m) where
>    mzero = MaybeT (return Nothing)
>    mplus x y = MaybeT $ do v <- runMaybeT x
>                            case v of
>                              Nothing -> runMaybeT y
>                              Just _  -> return v
> It is also the one I needed recently.

I tend to agree that this is the right one to use, but I think care
should be taken when adding this to what is/is expected to be a widely
used package, as it could make it difficult for people who want the
alternate behaviour, and it might imply a degree of standardisation/
canonicity that is not really justified.

On the other hand, perhaps there are no real uses for the other one.



Please access the attached hyperlink for an important electronic communications disclaimer:

More information about the Libraries mailing list