<div><span class="gmail_quote">On 12/6/07, <b class="gmail_sendername">Ryan Ingram</b> &lt;<a href="mailto:ryani.spam@gmail.com">ryani.spam@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div><span class="q"><span class="gmail_quote">On 12/6/07, <b class="gmail_sendername">Luke Palmer</b> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:lrpalmer@gmail.com" target="_blank">lrpalmer@gmail.com
</a>&gt; wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I have actually seen this pattern a lot recently.&nbsp;&nbsp;Recently I have<br>started using a function:<br><br>mergeMaybes :: (a -&gt; a -&gt; a) -&gt; Maybe a -&gt; Maybe a -&gt; Maybe a 
<br>mergeMaybes f Nothing y = y<br>mergeMaybes f x Nothing = x<br>mergeMaybes f (Just x) (Just y) = Just (f x y)</blockquote>
<div>&nbsp;</div></span>
<div>mergeMaybes = liftM2 -- from Control.Monad</div></div></blockquote>
<div>&nbsp;</div>
<div>Oh wait, not quite.&nbsp; Didn&#39;t realize you were returning the intermediate values in the &quot;not nothing&quot; case.</div>
<div>&nbsp;</div>
<div>mergeMaybes f x y = liftM2 f `mplus` x `mplus` y</div><br>&nbsp;</div>