<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 20 Apr 2009, at 09:41, Peter Verswyvelen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I was wandering if it would be possible to optimize <a href="http://hackage.haskell.org/packages/archive/unamb/0.1.9/doc/html/Data-Unamb.html#v%3Aunamb">unamb</a>&nbsp;by checking if a value is already evaluated to head normal form.&nbsp;<div> <br></div><div>So&nbsp;</div><div><br></div><div>f `unamb` g</div><div><div><br></div><div>would then be extremely fast if either f or g is already evaluated to head normal form.&nbsp;</div><div><br></div><div><div>Maybe using some vacuum tricks?</div> <div><br></div><div><div>This function would need to be in IO since it is of course not referentially transparent.</div></div></div></div></blockquote><div><br></div><div>Really? &nbsp;Is it any less referentially transparent than unamb already is - i.e. it's referentially transparent, as long as the two values really are equal.</div><br><blockquote type="cite"><div><div><div><div><span class="Apple-style-span" style="color: rgb(0, 0, 0); ">Although threads are lightweight in Haskell, forking/waiting/killing surely must have more overhead than just checking the thunk of an expression?</span></div></div></div> <div><br></div><div>Of course one could also make unamb a primitive :-)</div></div></blockquote><br></div><div>That would be a lovely solution for me.</div><div><br></div><div>Bob</div></body></html>