<p dir="ltr">Consider the implementation of `second` for pairs:</p>
<p dir="ltr">second f ~(a,b) = (a, f b)</p>
<p dir="ltr">Now</p>
<p dir="ltr">fix $ second (3 :)</p>
<p dir="ltr">Will be (undefined, [3,3,....])</p>
<p dir="ltr">Translating this to IO, I'd want</p>
<p dir="ltr">lazyMap f undefined</p>
<p dir="ltr">to produce as much as possible of the result, although it cannot produce the final State# RealWorld token.</p>
<div class="gmail_quote">On Apr 18, 2016 4:47 PM, "David Turner" <<a href="mailto:dct25-561bs@mythic-beasts.com">dct25-561bs@mythic-beasts.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">You can't know that the final result of the computation (x `seq` (3:...)) will begin with 3, because sometimes it doesn't! More specifically, it diverges (without yielding the 3) if x diverges.</p>
<p dir="ltr">I don't think this is anything special about mfix: (let x = x `seq` 3:... in x) also diverges for the same reason.</p>
<p dir="ltr">Hope that helps,</p>
<p dir="ltr">David</p>
<div class="gmail_quote">On 18 Apr 2016 21:19, "David Feuer" <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If<br>
<br>
f :: a -> IO a<br>
<br>
for some a, and I want to use<br>
<br>
mfix f<br>
<br>
then f must not inspect its argument in any way, or the computation<br>
will get stuck. In some cases, this seems a bit harsh. For example,<br>
<br>
mfix (\x -> fmap (3 :) (x `seq` readLn))<br>
<br>
looks perfectly reasonable. There is no need to inspect the return []<br>
action to know that the final result of the computation will begin<br>
with 3:. Is there a lazy IO mapping function somewhere that can work<br>
such magic?<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div>
</blockquote></div>