<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>I'm new to Haskell and trying to get a better understanding
of sharing (and ultimately memoization).&nbsp; I've read SOE and various of the
tutorials, as well as browsing around the wiki and old mailing lists.&nbsp; <o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Most of the examples of memoization seem to revolve around
Fibonacci, and are based either on the fact that a list defined within the
function will get shared between calls, or on doing some 'unsafeIO' (which I
haven't dug too deeply into.)&nbsp;&nbsp; <o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I've read various discussions that explain why function
calls are generally not automatically memoized (e.g. f x &nbsp;gets
recalculated rather than looked up based on the prior result).&nbsp; The
rationale for that (big space leak and no guarantee of improved performance)
makes sense.&nbsp; (Though I did like one poster's suggestion of a compiler
pragma that hints that a particular function should be memoized.)<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I've seen other discussions that suggest that lists are
always shared while in scope (so the fibs trick works).&nbsp; But is that just
a feature of the standard compilers, or is it somewhere mandated in the Hakell
spec (I don't see anything obvious in the Haskell Report tho haven't read it
cover to cover)? <o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>The wiki page <a
href="http://www.haskell.org/haskellwiki/Performance/Strictness">http://www.haskell.org/haskellwiki/Performance/Strictness</a>
&nbsp;says laziness == non-strictness + sharing but again nowhere gives a set
of rules that guarantees what will be shared and what won't.&nbsp; I was hoping
I might find it here: <a href="http://www.haskell.org/haskellwiki/Sharing">http://www.haskell.org/haskellwiki/Sharing</a>
but no such luck.&nbsp; Or are there no guarantees and you just have to know
how your particular compiler works??<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Cheers,<o:p></o:p></p>

<p class=MsoNormal>Patrick<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>


<BR>
________________________________________________________________________<BR>
DISCLAIMER: This e-mail is intended only for the addressee named above. As this e-mail may contain confidential or privileged information, if you are not the named addressee, you are not authorised to retain, read, copy or disseminate this message or any part of it. If you received this email in error, please notify the sender and delete the message from your computer.<BR>
</body>

</html>