<br><br><div class="gmail_quote">On Thu, Feb 5, 2009 at 2:38 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="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="Wj3C7c">On Thu, 2009-02-05 at 13:01 -0800, David Leimbach wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Feb 5, 2009 at 12:27 PM, Jonathan Cast<br>
&gt; &lt;<a href="mailto:jonathanccast@fastmail.fm">jonathanccast@fastmail.fm</a>&gt; wrote:<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; On Thu, 2009-02-05 at 12:21 -0800, David Leimbach wrote:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; On Thu, Feb 5, 2009 at 11:25 AM, Andrew Wagner<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &lt;<a href="mailto:wagner.andrew@gmail.com">wagner.andrew@gmail.com</a>&gt; wrote:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I think the point of the Monad is<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; that it<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; works as a container of stuff, that<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; still<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allows mathematically pure things to<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; happen,<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while possibly having some opaque<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &quot;other<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stuff&quot; going on.<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;This at least sounds, very wrong, even if it&#39;s not.<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Monads<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; are not impure. IO is, but it&#39;s only _one_ instance<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; of Monad.<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; All others, as far as I know, are pure. It&#39;s just<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; that the<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; bind operation allows you to hide the stuff you<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; don&#39;t want to<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; have to worry about, that should happen every time<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; you compose<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; two monadic actions.<br>
<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; Well all I can tell you is that I can have (IO Int) in a<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; function as a<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; return, and the function is not idempotent in terms of the<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &quot;stuff&quot;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; inside IO being the same.<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Sure it&#39;s the same.<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; &nbsp;cmp /bin/cat /bin/cat<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; cp /bin/cat ~<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; cmp /bin/cat ~/cat<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Pretty much the same, anyway.<br>
<br>
</div></div><div class="Ih2E3d">&gt; So if IO represents a program that when executed interacts with the<br>
&gt; world&#39;s state, is it safe to say that when I return (State Int Int),<br>
&gt; that I&#39;m returning a &quot;State program&quot;?<br>
<br>
</div>I won&#39;t object to it. &nbsp;Othe people might, though.<br>
<div class="Ih2E3d"><br>
&gt; That&#39;d make sense as it really does look like we force the State to be<br>
&gt; evaluated with runState, evalState or execState.<br>
<br>
&gt; The only difference with IO then is that to get IO programs to run,<br>
&gt; you have to do it inside another IO program.<br>
<br>
</div>Meh. &nbsp;Combining IO sub-programs into larger programs doesn&#39;t really `get<br>
them to run&#39;. &nbsp;Better to say that an IO value is meaningful only to the<br>
computer, and not mathematically (denotationally) useful.<br>
<br>
jcc<br></blockquote><div><br></div><div>All Haskell programs start as&nbsp;</div><div><br></div><div>main :: IO ()</div><div><br></div><div>though... so they all get evaluated in the context of another IO () don&#39;t they?</div>
<div><br></div><div><br></div><div>&nbsp;</div></div><br><div><br></div>