<br><br><div class="gmail_quote">On Sat, Jul 28, 2012 at 8:00 AM, Thiago Negri <span dir="ltr">&lt;<a href="mailto:evohunz@gmail.com" target="_blank">evohunz@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I&#39;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&#39;m missing a function to transform a Maybe a into a MonadPlus m =&gt; m a.<br>
I did search on Hoogle with no luck.<br>
<br>
There is no standard definition for the &quot;g&quot; function I&#39;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) =&gt; Maybe a -&gt; m a<br>
g Nothing = mzero<br>
g (Just a) = return a<br></blockquote><div><br></div><div>I doubt there is a &quot;standard&quot; named function for this, since conversions between monads are typically not &quot;unique&quot; 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>