I came up with a system of coloring -- you'll have to view this message as html to see it.  You start with the input parameters -- those are green.  Anything defined in terms of green is blue.  Anything defined in terms of green & blue is purple.  Anything defined in terms of green, blue, and purple is orange, etc.  Then you can see the problem.  So in foo, everything checks out, you get to orange and there's just a couple of expressions left and you can see that there's no loop.
<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="direction: ltr;"><div style="direction: ltr;"><div><pre>-----------------------------------------------------------------------------------------------------------
<br><br> foo  <span style="color: rgb(51, 204, 0);">(</span><span style="background-color: rgb(255, 255, 255); color: rgb(51, 204, 0);">step,r0,mu0</span><span style="color: rgb(51, 204, 0);">)</span> = bar (<span style="color: rgb(51, 204, 0);">
step</span>,r1,<span style="color: rgb(51, 204, 0);">r0</span>,mu1,<span style="color: rgb(51, 204, 0);">mu0</span>)<br>    where<br>    r1 = <span style="color: rgb(51, 204, 0);">r0</span>-<span style="color: rgb(51, 204, 0);">
step</span>*<span style="color: rgb(255, 204, 51);">rd</span><br>    mu1 = <span style="color: rgb(51, 204, 0);">mu0</span>-<span style="color: rgb(51, 204, 0);">step</span>*<span style="color: rgb(255, 204, 51);">mud</span>
<br><br>    <span style="color: rgb(255, 204, 51);">rd</span> = <span style="color: rgb(204, 51, 204);">c*c</span>*<span style="color: rgb(51, 204, 0);">mu0</span><br>    <span style="color: rgb(255, 204, 51);">mud</span>
 = <span style="color: rgb(204, 51, 204);">c*c</span>/<span style="color: rgb(51, 204, 0);">r0</span> - (foobar_r <span style="color: rgb(51, 102, 255);">z</span>)/<span style="color: rgb(204, 51, 204);">c</span><br>    <span style="color: rgb(204, 51, 204);">
c</span> = baz(<span style="color: rgb(51, 102, 255);">z</span>)<br>    <span style="color: rgb(51, 102, 255);">z</span> = 6.378388e6-<span style="color: rgb(51, 204, 0);">r0</span><br><br>baz z | z&lt;125 = -0.25*z+1537.5
<br>        | otherwise = 0.0169*z+1504.1<br><br>foobar_r z | z&lt;125 = 0.25<br>
    | otherwise = -0.0169</pre></div></div></div></blockquote><div><br>But when you try coloring bar, you get this far and then we're stuck.&nbsp; The problem is clear: r depends on rdc, which depends on rd0, which depends on c0, which depends on z0, which depends on r.&nbsp; So your definition for r includes a loop.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="direction: ltr;"><div style="direction: ltr;"><div><pre>bar <span style="color: rgb(51, 204, 0);">
(step,r2,r1,mu2,mu1)</span> = (r,z0) : bar (<span style="color: rgb(51, 204, 0);">step,r1</span>,r,<span style="color: rgb(51, 204, 0);">mu1</span>,m)<br>    where<br>    r = <span style="color: rgb(51, 204, 0);">r2</span>
+2*<span style="color: rgb(51, 204, 0);">step</span>*rdc<br>    m = <span style="color: rgb(51, 204, 0);">mu2</span>+2*<span style="color: rgb(51, 204, 0);">step</span>*mudc<br>    rdc = (<span style="color: rgb(255, 204, 51);">
rd2+rd1</span>+rd0)/6<br>    mudc = (<span style="color: rgb(255, 204, 51);">mud2+mud1</span>+mud0)/6<br>
<br>    <span style="color: rgb(255, 204, 51);">rd2</span> = <span style="color: rgb(204, 51, 204);">c2*c2</span>*<span style="color: rgb(51, 204, 0);">mu2</span><br>    <span style="color: rgb(255, 204, 51);">mud2</span>
 = <span style="color: rgb(204, 51, 204);">c2*c2</span>/<span style="color: rgb(51, 204, 0);">r2</span> - (foobar_r <span style="color: rgb(51, 102, 255);">z2</span>)/<span style="color: rgb(204, 51, 204);">c2</span><br><br>
    <span style="color: rgb(255, 204, 51);">rd1</span> = <span style="color: rgb(204, 51, 204);">c1*c1</span>*<span style="color: rgb(51, 204, 0);">mu1</span><br>    <span style="color: rgb(255, 204, 51);">mud1</span> = <span style="color: rgb(204, 51, 204);">
c1*c1</span>/<span style="color: rgb(51, 204, 0);">r1</span> - (foobar_r <span style="color: rgb(51, 102, 255);">z1</span>)/<span style="color: rgb(204, 51, 204);">c1</span><br><br>    rd0 = c0*c0*m<br><span></span>    mud0 = c0*c0/r - (foobar_r z0)/c0
<br><br>    <span style="color: rgb(204, 51, 204);">c2</span> = baz(<span style="color: rgb(51, 102, 255);">z2</span>)<br><br>    <span style="color: rgb(204, 51, 204);">c1</span> = baz(<span style="color: rgb(51, 102, 255);">
z1</span>)<br>    c0 = baz(z0)<br><br>    <span style="color: rgb(51, 102, 255);">z2</span> = 6.378388e6-<span style="color: rgb(51, 204, 0);">r2</span><br>    <span style="color: rgb(51, 102, 255);">z1</span> = 6.378388e6
-<span style="color: rgb(51, 204, 0);">r1</span><br>    z0 = 6.378388e6-r<br><br>main :: IO ()<br>main = do<br>    print $ take 100 (foo (0.1, 6.378388e6,0))</pre>
<br>
&nbsp;</div><br></div><br>

</div></blockquote></div><br>