On Sun, May 3, 2009 at 4:41 AM, Luke Palmer <span dir="ltr">&lt;<a href="mailto:lrpalmer@gmail.com">lrpalmer@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
mplus requires both arguments to be in the same monad (the same type, even).   Fortunately, the empty list behaves like Nothing, and a singleton list behaves like Just.  So convert the Maybe before composing, using:<br><br>

maybeToList Nothing = []<br>maybeToList (Just x) = [x]<br><br>(The maybeToList function can be found in Data.Maybe)<br><br>Keep in mind that this will give you:<br><br>Just 1 `mplus` [2,3,4]  ==&gt;  [1,2,3,4]</blockquote>
<div><br>Silly me:<br><br>maybeToList (Just 1) `mplus` [2,3,4] ==&gt; [1,2,3,4]<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br>Which may not be what you want...<br>
<br>Luke<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Sat, May 2, 2009 at 9:26 PM, michael rice <span dir="ltr">&lt;<a href="mailto:nowgate@yahoo.com" target="_blank">nowgate@yahoo.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">

I posted something similar about an hour ago but it seems to have gotten lost. Very strange.<br><br>I&#39;ve read that Monads can combine computations. Can a Maybe monad be combined with a List monad such that<br><br>Nothing `mplus` [] ==&gt; [] <br>

Just 1 `mplus` [] ==&gt; [1]<br><br>If not, can someone supply a simple example of combining computations?<br><br>Michael<br><br></td></tr></tbody></table><br>



      <br></div></div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>
</blockquote></div><br>