<div>Hi ,</div>
<div>     With help I got the following to print out each step in the evaluation of the add. However I was just wondering if it was possible to make the evaluation go back one step at a time. I tried to use a get count function but this doesnt seem so easy. </div>

<div> </div>
<div>data Expression = Val Integer<br>                | Add Expression Expression<br>                | Subtract Expression Expression<br>                | Multiply Expression Expression<br>                | Divide Expression Expression<br>
         deriving Show<br>demo1 = (Add(Add(Add(Add(Val 6)(Val 5))(Val 10))(Val 7))(Val 30))</div>
<div>evalStep :: Expression -&gt;  Expression<br>evalStep (Val x)=  (Val x) </div>
<div>evalStep (Add x y)<br>   = case x of<br>       (Val a) -&gt; case y of<br>                    (Val b) -&gt; Val (a+b)<br>                    left -&gt; Add x (evalStep y)<br>       right -&gt; Add (evalStep x)y <br>
 <br>evaluate :: Expression -&gt;  IO ()</div>
<div>-- Base case<br>evaluate (Val a) = return ()</div>
<div><br>-- Recursive case<br>evaluate e = do<br>      putStrLn &quot;Evaluating one more step&quot;<br>      let e&#39; =  (evalStep e)<br>      putStrLn (&quot;Result is &quot;++(show e&#39;))<br>      putStrLn &quot;Do another step (y/n)? :&quot;<br>
      c &lt;- getLine<br>             if (c==&quot;y&quot;)then<br>         evaluate e&#39;<br>       else putStrLn(&quot;Ok you said&quot; ++ show[c] ++ &quot;so that&#39;s it&quot; ++ show getCount)<br>   <br>getCount:: Expression -&gt;  Int<br>
getCount e&#39; = n, n=1<br>          <br> if(getCount == 1) then  <br>            putStrLn (&quot;Cannot go back&quot;)<br>  else putStrLn (&quot;One step back&quot; ++ show n-1)</div>
<div> </div>
<div>All thoughts welcome!</div>
<div> </div>
<div>john<br>               <br>             </div>