
26 Dec
2010
26 Dec
'10
2:23 p.m.
instance Monad m => MonadPlus (MaybeT m) where mzero = MaybeT $ return Nothing mplus x y = MaybeT $ do maybe_value <- runMaybeT x case maybe_value of Nothing -> runMaybeT y Just _ -> return maybe_value
I've not run it so with some caution, I'd expect this to work - the last line is now returning the first answer with 'return' of the wrapped monad. I'm not sure if this is a lawful version of mplus though...