No one replied to this, but I think I figured out why, when I am using the Error monad, that every statement in a do construct runs at least part way, whether or not its data is needed. The final output is a Left or Right value -- and because a Left anywhere can short-circuit the compuation that follows, there is no way for the program to decide on a final Left/Right output without running each computation (or at least up to the point where it&#39;s not a Left).<br>
<br><div class="gmail_quote">On Sat, Sep 1, 2012 at 12:59 PM, Dennis Raddle <span dir="ltr">&lt;<a href="mailto:dennis.raddle@gmail.com" target="_blank">dennis.raddle@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I recently completed a large project and started another one. The first project was about processing music, in particular taking MusicXML and/or Sibelius files (Sibelius is a music notation program) and producing MIDI files according to the specifications I wanted.<br>

<br>The second project is about algorithmic music composition.<br><br>To handle errors in the first project, I used &quot;throw&quot; to throw exceptions. <br><br>Now I am using the Error monad... actually a combination of ErrorT and State. (In the state I hold a random generator for use in algorithms that require pseudo-randomness.)<br>

<br>I notice two things now. The first thing is that I can catch and rethrow errors to provide annotation about the context. It&#39;s like getting a stack trace automatically every time there is an error. I realize now this makes it easier to debug, and during my first project I spent a lot of time debugging that might have been avoidable. (I confess I never could figure out the ghci debugger, which might have helped.)<br>

<br>The second thing is that there seems to be less laziness. Every statement in a do statement seems to execute even if I don&#39;t use result. I think. I would have to do some more experiments, but that is what it looks like right now. That is another good thing for debugging... less laziness (and maybe guaranteed order of execution too?) means it&#39;s easier to understand what the program is attempting to do.<br>

<br>Does this seem correct?<span class="HOEnZb"><font color="#888888"><br><br>Dennis<br><br>
</font></span></blockquote></div><br>