[Haskell-cafe] MonadPlus m => Maybe a -> m a
alex.solla at gmail.com
Sat Jul 28 18:17:44 CEST 2012
On Sat, Jul 28, 2012 at 8:00 AM, Thiago Negri <evohunz at gmail.com> wrote:
> I'm solving this exercise:
> I'm missing a function to transform a Maybe a into a MonadPlus m => m a.
> I did search on Hoogle with no luck.
> There is no standard definition for the "g" function I'm defining?
g :: (MonadPlus m) => Maybe a -> m a
> g Nothing = mzero
> g (Just a) = return a
I doubt there is a "standard" named function for this, since conversions
between monads are typically not "unique" and there are lots and lots of
pairs of monads you can convert between.
You can define g in terms of Data.Maybe.maybe as:
g = maybe mzero return
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe