<br><br><div class="gmail_quote">On Sat, Jul 28, 2012 at 8:00 AM, Thiago Negri <span dir="ltr"><<a href="mailto:evohunz@gmail.com" target="_blank">evohunz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm solving this exercise:<br>
<a href="http://www.haskell.org/haskellwiki/All_About_Monads#Exercise_4:_Using_the_Monad_class_constraint" target="_blank">http://www.haskell.org/haskellwiki/All_About_Monads#Exercise_4:_Using_the_Monad_class_constraint</a><br>
<br>
I'm missing a function to transform a Maybe a into a MonadPlus m => m a.<br>
I did search on Hoogle with no luck.<br>
<br>
There is no standard definition for the "g" function I'm defining? </blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
g :: (MonadPlus m) => Maybe a -> m a<br>
g Nothing = mzero<br>
g (Just a) = return a<br></blockquote><div><br></div><div>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.</div>
<div><br></div><div>You can define g in terms of Data.Maybe.maybe as:</div><div><br></div><div>g = maybe mzero return</div></div>