Oh, you&#39;re right.  Here are some thoughts.<br><br>You want the list you get back to only contain values in WHNF.  This differs from mergeIO &amp; co., which are simply evaluating the spine of the list, and don&#39;t even look at the values.  <br>
<br>I would also consider it bad style to be fully polymorphic in this case, as you require polymorphic seq, which is evil (though I don&#39;t have the space to argue this right now :-).  Unamb would be bad style, also, since your semantics are nondeterministic and so you wouldn&#39;t meet the precondition.  Surely your result would have to be in IO.  (&quot;amb&quot; would be okay)<br>
<br>Here is how I would do it:<br><br><font face="courier new,monospace">chooseIO :: [IO a] -&gt; IO [a]<br>chooseIO xs = do<br>    chan &lt;- newChan<br>    let eval io = forkIO (io &gt;&gt;= writeChan chan)<br>    forkIO $ mapM_ eval xs<br>
    getChanContents chan<br></font><br>(The list never ends in this case, even when xs is finite.  I think it&#39;s possible to make the result finite with the argument is, and maintain good GC properties, but it would take some care)<br>
<br>The reason I take a list of [IO a] is to avoid polymorphic seq; the elements of the list have built in what it means to evaluate them.  This also buys you more flexibility (but also fewer guarantees...).<br><br>For the working Haskeller, it is safe to avoid all this pedantic zealotry... I&#39;m just being a purist.<br>
<br>Luke<br><br><br><br><div class="gmail_quote">On Tue, Mar 10, 2009 at 5:31 PM, Anatoly Yakovenko <span dir="ltr">&lt;<a href="mailto:aeyakovenko@gmail.com">aeyakovenko@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
i think this would still force me to evailuate the whole list, right?<br>
i would want something that pipes the results into a channel that i<br>
can lazyly read as the results are available.<br>
<div><div></div><div class="h5"><br>
On Tue, Mar 10, 2009 at 2:44 PM, Luke Palmer &lt;<a href="mailto:lrpalmer@gmail.com">lrpalmer@gmail.com</a>&gt; wrote:<br>
&gt; I think nmergeIO . map (:[]) should do the trick.<br>
&gt;<br>
&gt; Luke<br>
&gt;<br>
&gt; On Tue, Mar 10, 2009 at 3:41 PM, Anatoly Yakovenko &lt;<a href="mailto:aeyakovenko@gmail.com">aeyakovenko@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hmm, yea, actually that makes sense.  What i am looking for is<br>
&gt;&gt; something that maps over a list and returns the list in order which<br>
&gt;&gt; the values are evaluated.  looks like i can implement that pretty<br>
&gt;&gt; easily with unamb.<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Mar 10, 2009 at 2:33 PM, Luke Palmer &lt;<a href="mailto:lrpalmer@gmail.com">lrpalmer@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; Although it is not formally specified, my intuition for the<br>
&gt;&gt; &gt; specification is<br>
&gt;&gt; &gt; that order is preserved within each of the lists.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Luke<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Tue, Mar 10, 2009 at 2:50 PM, Anatoly Yakovenko<br>
&gt;&gt; &gt; &lt;<a href="mailto:aeyakovenko@gmail.com">aeyakovenko@gmail.com</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; do nmergeIO or mergeIO preserve order? or not preserve order?<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; Haskell-Cafe mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt;&gt; &gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>