I am interested in reasoning about a code,  say for example:<br><br><pre class="haskell"><span style="color: rgb(0, 0, 153);">data</span> DList a = DLNode <span style="color: black;">(</span>DList a<span style="color: black;">)</span> a <span style="color: black;">(</span>DList a<span style="color: black;">)</span><br>
 <br>mkDList <span style="color: rgb(0, 0, 153);">::</span> <span style="color: black;">[</span>a<span style="color: black;">]</span> <span style="color: rgb(0, 0, 153);">-&gt;</span> DList a<br> <br>mkDList <span style="color: black;">[</span><span style="color: black;">]</span> = <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:error"><span style="color: rgb(0, 102, 0);">error</span></a> <span style="color: rgb(0, 51, 0);">&quot;must have at least one element&quot;</span><br>
mkDList xs = <span style="color: rgb(0, 0, 153);">let</span> <span style="color: black;">(</span>first,<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last"><span style="color: rgb(0, 102, 0);">last</span></a><span style="color: black;">)</span> = go <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last"><span style="color: rgb(0, 102, 0);">last</span></a> xs first<br>
             <span style="color: rgb(0, 0, 153);">in</span>  first<br> <br>  <span style="color: rgb(0, 0, 153);">where</span> go <span style="color: rgb(0, 0, 153);">::</span> DList a <span style="color: rgb(0, 0, 153);">-&gt;</span> <span style="color: black;">[</span>a<span style="color: black;">]</span> <span style="color: rgb(0, 0, 153);">-&gt;</span> DList a <span style="color: rgb(0, 0, 153);">-&gt;</span> <span style="color: black;">(</span>DList a, DList a<span style="color: black;">)</span><br>
        go prev <span style="color: black;">[</span><span style="color: black;">]</span>     next = <span style="color: black;">(</span>next,prev<span style="color: black;">)</span><br>        go prev <span style="color: black;">(</span>x:xs<span style="color: black;">)</span> next = <span style="color: rgb(0, 0, 153);">let</span> this        = DLNode prev x rest<br>
                                  <span style="color: black;">(</span>rest,<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last"><span style="color: rgb(0, 102, 0);">last</span></a><span style="color: black;">)</span> = go this xs next<br>
<br><br>                              <span style="color: rgb(0, 0, 153);">in</span>  <span style="color: black;">(</span>this,<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last"><span style="color: rgb(0, 102, 0);">last</span></a><span style="color: black;">)</span><br>
<br>takeF <span style="color: rgb(0, 0, 153);">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"><span style="color: rgb(102, 0, 0);">Integer</span></a> <span style="color: rgb(0, 0, 153);">-&gt;</span> DList a <span style="color: rgb(0, 0, 153);">-&gt;</span> <span style="color: black;">[</span>a<span style="color: black;">]</span><br>
takeF <span style="color: rgb(0, 51, 0);">0</span>     <span style="color: rgb(0, 0, 153);">_</span>                 = <span style="color: black;">[</span><span style="color: black;">]</span><br>takeF <span style="color: black;">(</span>n<span style="color: rgb(0, 51, 0);">+1</span><span style="color: black;">)</span> <span style="color: black;">(</span>DLNode <span style="color: rgb(0, 0, 153);">_</span> x next<span style="color: black;">)</span> = x : <span style="color: black;">(</span>takeF n next<span style="color: black;">)</span><br>
<br><br>With the debugger I can see the calls that are made when I run:<br> <br><br>takeF 2 (mkDList [1,2,3])<br><br>But I am more interested in seeing the expansion and reduction that the execution encounters as it lazily evaluates the function.<br>
<br><br>Daryoush<br></pre><br><br><div class="gmail_quote">On Tue, Mar 31, 2009 at 6:49 PM, Bernie Pope <span dir="ltr">&lt;<a href="mailto:florbitous@gmail.com">florbitous@gmail.com</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><div class="gmail_quote">2009/4/1 Daryoush Mehrtash <span dir="ltr">&lt;<a href="mailto:dmehrtash@gmail.com" target="_blank">dmehrtash@gmail.com</a>&gt;</span><div class="im"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br clear="all">I am trying to write out the execution of the recursive calls in <a href="http:/http://www.haskell.org/haskellwiki/Tying_the_Knot/www.haskell.org/haskellwiki/Tying_the_Knot" target="_blank">mkDList example</a> for different size lists.  Is there a way in ghc, or ghci where for a given list I can see the intermediate recursive and evaluation steps?<br>

</blockquote></div></div><br></div><div>Have you tried stepping through the code using the GHCi debugger?<div><br></div><div>    <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html" target="_blank">http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html</a></div>

<div><br></div><div>If you have tried, but it didn&#39;t satisfy your needs, could you explain what is lacking?</div></div>
</blockquote></div><br><br>