Micheal, I think you mean<br><br>do <br>&nbsp; x &lt;- if .. then ..<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else ..<br>&nbsp; y &lt;- if ... then.. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else... <br><br>etc etc<br><br><div><span class="gmail_quote">On 6/25/07, <b class="gmail_sendername">
Michael T. Richter</b> &lt;<a href="mailto:ttmrichter@gmail.com">ttmrichter@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



  
  

<div>
Now I&#39;ve got a situation I can&#39;t figure out how to resolve.&nbsp; I want to have a set of actions which are executed sequentially, but which, before I even <b>start</b> to execute the first one, have been inspected for legality and/or plausibility.&nbsp; Consider this kind of sequence:
<br>
<br>
<tt>do</tt><br>
<tt>&nbsp; x &lt;- performActionA</tt><br>
<tt>&nbsp; y &lt;- performActionB</tt><br>
<tt>&nbsp; z &lt;- performActionC</tt><br>
<tt>&nbsp; return $ calculateStuff x y z</tt><br>
<br>
Now obviously this is going to be in a monad of some kind.&nbsp; Were this a regular, run-of-the-mill program I&#39;d just use the IO monad.&nbsp; But what I want to do instead is, before executing any of the perform* functions, check that the actions desired are actually 
<b>permitted</b> (or possible) given a set of circumstances.&nbsp; For example let&#39;s say it&#39;s a permissions issue and performActionB can only be done if I&#39;m root.&nbsp; If I&#39;m not root I don&#39;t want performActionA done because I can&#39;t complete the transaction.&nbsp; (Maybe ActionA is non-reversible, say.)&nbsp; Or let&#39;s say this is code that&#39;s accessing databases on the network.&nbsp; If the network link to C can&#39;t be established, I don&#39;t want to screw around with A and B&#39;s links at all -- it&#39;s too expensive, too time-consuming or whatever.
<br>
<br>
Were I programming this in C, C++, Python, Ruby, etc. I could do this in my sleep.&nbsp; Functions are addresses (C/C++) or objects with an ID (Python/Ruby) so it&#39;s possible to take them and do some kind of check based on identities before executing things (although the scaffolding around this would be nontrivial in any of these languages except, possibly, Ruby).&nbsp; Functions in Haskell don&#39;t have this property, however, so I can&#39;t figure out what I&#39;d do to perform similar work.&nbsp; I&#39;m sure there&#39;s a way to do it, but I just can&#39;t see it.
<br>
<br>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td>
-- <br>
<b>Michael T. Richter</b> &lt;<a href="mailto:ttmrichter@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">ttmrichter@gmail.com</a>&gt; (<b>GoogleTalk:</b> <a href="mailto:ttmrichter@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
ttmrichter@gmail.com</a>)<br>
<i>I&#39;m not schooled in the science of human factors, but I suspect surprise is not an element of a robust user interface. (Chip Rosenthal)</i>
</td>
</tr>
</tbody></table>
</div>

<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br><br><br clear="all"></blockquote></div><br>