<div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks Isaac! It never crossed my mind that the problem was on the left hand side. </div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 12, 2014 at 3:36 AM, Isaac Dupree <span dir="ltr"><<a href="mailto:ml@isaac.cedarswampstudios.org" target="_blank">ml@isaac.cedarswampstudios.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":5m1" style="overflow:hidden">[...]<br>
In this situation, if interleaveStreams evaluates its second argument before returning any work, it will never be able to return.  Happily, the outer Cons of the result does not depend on the second argument.  I can fix the issue just by making the second argument be pattern-matched lazily (with ~, i.e. only as soon as any uses of the argument in the function are evaluated):</div>
</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":5m1" style="overflow:hidden">
interleaveStreams (Cons a as) ~(Cons b bs) = Cons a (Cons b (interleaveStreams as bs))<br><br>
<br></div></blockquote><div>So that's what the ~ does... :) </div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":5m1" style="overflow:hidden">

I'm not sure whether there's a practical difference between these and Data.Stream's definition.  Actually, I think they turn out to do exactly the same thing...<br></div></blockquote></div>Yes, they do. I used the solution in Data.Stream to fix mine, though I didn't recognize the true source of the problem until you pointed it out. Thanks again!<br>
<br></div></div>