On Wed, Mar 18, 2009 at 6:21 AM, Chung-chieh Shan <span dir="ltr"><<a href="mailto:ccshan@post.harvard.edu">ccshan@post.harvard.edu</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;">
Sebastiaan Visser <<a href="mailto:sfvisser@cs.uu.nl">sfvisser@cs.uu.nl</a>> wrote in article <<a href="mailto:D86A7D11-F95F-4A27-A13C-2D78AFDA2E02@cs.uu.nl">D86A7D11-F95F-4A27-A13C-2D78AFDA2E02@cs.uu.nl</a>> in gmane.comp.lang.haskell.cafe:<br>
<div class="im">> Suppose I have a list of IO computations that depends on a few very<br>
> time consuming pure operations. The pure operations are not dependent<br>
> on the real world:<br>
><br>
> > computation :: [IO Int]<br>
> > computation = [<br>
> > smallIOfunc timeConsumingPureOperation0<br>
> > , smallIOfunc timeConsumingPureOperation1<br>
> > , smallIOfunc timeConsumingPureOperation2<br>
> > , smallIOfunc timeConsumingPureOperation3<br>
> > ]<br>
> > where smallIOfunc a = print a >> return a<br>
<br>
</div>I take it that, because you "do not really have the control to change<br>
things `deep' inside the code", it is not an option to redefine<br>
<br>
computation = [<br>
smallIOfunc x0<br>
, smallIOfunc x1<br>
, smallIOfunc x2<br>
, smallIOfunc x3<br>
<div class="im"> ]<br>
where smallIOfunc a = print a >> return a<br>
</div> x0 = timeConsumingPureOperation0<br>
x1 = timeConsumingPureOperation1<br>
x2 = timeConsumingPureOperation2<br>
x3 = timeConsumingPureOperation3</blockquote><div><br>Um, just to clarify, this code is exactly equivalent to the original, including sharing behavior. The only time a let (or where) clause changes sharing is if the variable is used more than once in the body.<br>
<br>Luke<br></div></div>