
3 May
2009
3 May
'09
7:04 a.m.
I don't know if I understood your intentions, but let's go. The problem is that you're trying to combine different monads. We have mplus :: MonadPlus m => m a -> m a -> m a, so you never leave 'm', but you want mplus' :: ??? => n a -> m a -> m a where 'n' could be a different monad. In some specific cases where you know the internal structure of the monad, you can write 'mplus'', for example: mplus' :: MonadPlus m => Maybe a -> m a -> m a mplus' m l = maybeToMonad m `mplus` l maybeToMonad :: Monad m => Maybe a -> m a maybeToMonad = maybe (fail "Nothing") return In general, however, this operation can't be done. For example, how would you write: mplus' :: IO a -> [a] -> [a] ? HTH, -- Felipe.