On Tue, May 5, 2009 at 3:27 PM, Luke Palmer <span dir="ltr"><<a href="mailto:lrpalmer@gmail.com">lrpalmer@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Sun, May 3, 2009 at 11:27 AM, Tobias Olausson <span dir="ltr"><<a href="mailto:tobsan@gmail.com" target="_blank">tobsan@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello!<br>
I have a program that is using ST.Strict, which works fine.<br>
However, the program needs to be extended, and to do that,<br>
lazy evaluation is needed. As a result of that, I have switched<br>
to ST.Lazy to be able to do stuff like </blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
foo y = do<br>
x <- something<br>
xs <- foo (y+1)<br>
return (x:xs)</blockquote></div><div><br>As Ryan points out, this will not do what you want. But that is incidental, not essential:<div class="im"><br><br>foo y = do<br> x <- something<br></div> fmap (x:) $ foo (y+1)</div>
</div></blockquote><div><br>Questioning my own reasoning, I must apologize. I was wrong, these two programs are identical and both do what you want.<br><br>Any references to the state <i>after</i> the infinite chain of foos will result in _|_, but as long as "something" is the only place that state calls occur, you will be fine.<br>
<br>I also suspect that ST.Lazy should be no less defined than ST.Strict in all cases, modulo unsafe operations of course (you aren't doing those, are you?), so you have encountered a bug. Minimize the test case and submit a bug report :-)<br>
<br>Luke</div></div><br>