<div dir="ltr">Is there a write up on what makes an implementation lazy vs strict?&nbsp;&nbsp; <br><br>I&nbsp; like to better understand the trade off between the two and use cases where one is better than the other.<br><br>I noticed that some functions in the lazy implementation uses &quot;~&quot; .&nbsp;&nbsp;&nbsp; For example<br>
<br><pre><span class="definition">evalStateT</span> <span class="keyglyph">::</span> <span class="layout">(</span><span class="conid">Monad</span> <span class="varid">m</span><span class="layout">)</span> <span class="keyglyph">=&gt;</span> <span class="conid">StateT</span> <span class="varid">s</span> <span class="varid">m</span> <span class="varid">a</span> <span class="keyglyph">-&gt;</span> <span class="varid">s</span> <span class="keyglyph">-&gt;</span> <span class="varid">m</span> <span class="varid">a</span><br>
<a name="line-151"></a><span class="definition">evalStateT</span> <span class="varid">m</span> <span class="varid">s</span> <span class="keyglyph">=</span> <span class="keyword">do</span><br><a name="line-152"></a>    <span class="keyglyph">~</span><span class="layout">(</span><span class="varid">a</span><span class="layout">,</span> <span class="keyword">_</span><span class="layout">)</span> <span class="keyglyph">&lt;-</span> <span class="varid">runStateT</span> <span class="varid">m</span> <span class="varid">s</span><br>
<a name="line-153"></a>    <span class="varid">return</span> <span class="varid">a</span><br><br></pre>What does ~ do?<br><br>thanks,<br><br>Daryoush<br><br><div class="gmail_quote">On Mon, Oct 13, 2008 at 1:34 PM, Jonathan Cast <span dir="ltr">&lt;<a href="mailto:jonathanccast@fastmail.fm">jonathanccast@fastmail.fm</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Mon, 2008-10-13 at 13:37 -0700, Daryoush Mehrtash wrote:<br>
&gt; Question 1: Why are there lazy and strict modules of some monads?<br>
</div>&gt; (e.g. Control.Monad.State)<br>
<br>
Because both are useful, for different purposes. &nbsp;(For the same reason<br>
that it&#39;s helpful, in general, to have both eager and lazy evaluation in<br>
the same language --- sometimes one version is more efficient, sometimes<br>
the other one is).<br>
&gt;<br>
&gt; Question 2: &nbsp;If I define a new monad (say XYZ), does it have to be as<br>
&gt; Control.Monad.XYZ &nbsp;module?<br>
<br>
No. &nbsp;Haskell has neither a requirement nor a convention that monads go<br>
in Control.Monad. &nbsp;Control.Monad.* is simply the home of the MTL<br>
library, which contains a number of exceptionally useful monads; new<br>
monads that aren&#39;t as exceptionally general-purpose as MTL probably<br>
shouldn&#39;t go there, to reduce clutter.<br>
<br>
jcc<br>
<br>
<br>
</blockquote></div><br><br>
</div>