<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Have you profiled it? I wouldn't worry about recursion until I've
      seen the problem. I believe GHC defaults to infinite stack size.<br>
    </p>
    <p>Have you tried using hp2ps and/or looking at the code via
      threadscope? <br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 06/19/2018 01:36 PM, Никита Фуфаев
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAHo=-3D42eF1ZeVjz+WeWz1b2goC_GK54GrCqTjdwbwkPp_g4w@mail.gmail.com">
      <div dir="ltr">Hello everyone<br clear="all">
        <div><br>
        </div>
        <div>In C you can't implement main loop with recursion like</div>
        <div>void mainLoop() {</div>
        <div>  doSomething();</div>
        <div>  mainLoop();</div>
        <div>}  </div>
        <div>because without optimisations stack will overflow.</div>
        <div>In haskell it's common to write</div>
        <div>mainLoop = doSomething >> mainLoop, and it doesn't
          leak memory because of haskell's evaluation model.</div>
        <div>Does memory leak or argument stack overflow happen in this
          case?</div>
        <div>mainLoop = doSomething >> mainLoop >> exit
          ExitSuccess</div>
        <div>What about this case?</div>
        <div>mainLoopModeA = do</div>
        <div>  doSomething</div>
        <div>  when condition mainLoopModeB</div>
        <div>  <span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">mainLoopModeA</span></div>
        <div>mainLoopModeB = do</div>
        <div>  doSomethingElse</div>
        <div>  when anotherCondition <span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">mainLoopModeA</span></div>
        <div><span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  <span
style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">mainLoopModeB</span></span></div>
        <div><span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span
style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br
                  class="gmail-Apple-interchange-newline">
                <span
style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">or
                  this case?</span></div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">mainLoopModeA
                = do</div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"> 
                doSomething</div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"> 
                if condition</div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"> 
                  then mainLoopModeB</div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"> 
                  else <span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">mainLoopModeA</span></div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">mainLoopModeB
                = do</div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"> 
                doSomethingElse</div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"> 
                if anotherCondition </div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> 
                    then mainLoopModeA</span></div>
              <div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> 
                    else <span
style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">mainLoopModeB</span></span></div>
            </span></span></div>
        <br>
        -- <br>
        <div class="gmail_signature" data-smartmail="gmail_signature">
          <div dir="ltr">
            <div dir="ltr">
              <div dir="ltr">Nikita Fufaev<br>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--'"--><br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
    </blockquote>
  </body>
</html>