<div dir="ltr">You can build this up using the >=< operator[1] in stm-conduit, something like:<div><br></div><div><div>eitherSrc :: MonadResourceBase m</div><div> => Source (ResourceT m) a -> Source (ResourceT m) b -> Source (ResourceT m) (Either a b)</div>
<div>eitherSrc src1 src2 = do</div><div> join $ lift $ Data.Conduit.mapOutput Left src1 >=< Data.Conduit.mapOutput Right src2</div><div><br></div><div>I think this can be generalized to work with more base monads with some tweaks to (>=<).</div>
<div><div><br></div><div>[1] <a href="http://haddocks.fpcomplete.com/fp/7.4.2/20130704-120/stm-conduit/Data-Conduit-TMChan.html#v:-62--61--60-">http://haddocks.fpcomplete.com/fp/7.4.2/20130704-120/stm-conduit/Data-Conduit-TMChan.html#v:-62--61--60-</a></div>
</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 23, 2013 at 11:32 AM, Erik de Castro Lopo <span dir="ltr"><<a href="mailto:mle+hs@mega-nerd.com" target="_blank">mle+hs@mega-nerd.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all<br>
<br>
Using the Conduit library is it possible to write the function:<br>
<br>
eitherSrc :: MonadResource m<br>
=> Source m a -> Source m b -> Source m (Either a b)<br>
<br>
which combines two sources into new output source such that data being<br>
produced aysnchronously by the original two sources will be returned<br>
as either a Left or Right of tne new source?<br>
<br>
If so, how?<br>
<br>
Cheers,<br>
Erik<br>
<span class="HOEnZb"><font color="#888888">--<br>
----------------------------------------------------------------------<br>
Erik de Castro Lopo<br>
<a href="http://www.mega-nerd.com/" target="_blank">http://www.mega-nerd.com/</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">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>
</font></span></blockquote></div><br></div>