Yes, GHC will rewrite this to<div><br></div><div> force x = x</div><div><br></div><div>I'm also not sure if we really want "seq" in all of these cases, or if we want stronger guarantees. For example, GHC can (and often will) rewrite</div>
<div><br></div><div> f x y = x `seq` y `seq` x</div><div><br></div><div>to</div><div><br></div><div> f x y = y `seq` x</div><div><br></div><div>This changes the order of evaluation. For pure computations this is semantically sound. However, it can change the space behaviour of the program, which defeats the point of using "seq" in the first place (usually). If forcing "x" to be evaluated before "y" is the goal, then "pseq" must be used. I think it's worthwhile to consider introducing high-level combinators for this use case as well.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On 15 November 2012 15:38, Johan Tibell <span dir="ltr"><<a href="mailto:johan.tibell@gmail.com" target="_blank">johan.tibell@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, Nov 15, 2012 at 2:38 AM, Henning Thielemann <span dir="ltr"><<a href="mailto:lemming@henning-thielemann.de" target="_blank">lemming@henning-thielemann.de</a>></span> wrote:</div>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<div>
On Mon, 12 Nov 2012, Bas van Dijk wrote:<br></div></div><div class="im"><div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
force :: WHNFData a => a -> a<br>
force x = x `seq` x<br>
</blockquote>
<br></div>
Does this function do something?</div></blockquote><div><br></div><div>No. It says "when x is evaluated, evaluate x". </div></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Push the envelope. Watch it bend.<br>
</div>