title: What is "fix" in Haskell? And why does "fix error" print an infinite string? And why also "take 10 $ fix error" does the same too?
body: <p>Long story short, I was watching <a href="https://www.youtube.com/watch?v=re96UgMk6GQ" rel="nofollow noreferrer">this lecture from Simon Peyton-Jones</a>, and at the time <a href="https://youtu.be/re96UgMk6GQ?t=1301" rel="nofollow noreferrer">21:41</a> he shows a quote:</p>
  <blockquote>
  <p>I was squashing a bug, got frustrated, and typed &quot;fix error&quot; in ghci…</p>
  </blockquote>
  <p>So I tried.</p>
  <p>Result:</p>
  <pre class="lang-hs prettyprint-override"><code>λ&gt; import Data.Function -- here is fix
  λ&gt; fix error
  &quot;*** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: *** Exception: and goes on like this towards infinity
  </code></pre>
  <p>At first, I simply thought <em>&quot;what the heck does this <code>fix</code> do?&quot;</em></p>
  <p>So I looked at some types:</p>
  <pre class="lang-hs prettyprint-override"><code>λ&gt; :t error
  error :: [Char] -&gt; a
  λ&gt; :t fix
  fix :: (a -&gt; a) -&gt; a
  </code></pre>
  <p>Hence,</p>
  <pre><code>λ&gt; :t fix error
  fix error :: [Char]
  </code></pre>
  <p>but clearly this still didn't tell me much about the result.</p>
  <p>What's most strange to me, though, is that even <code>take 10 $ fix error</code> or <code>length $ take 10 $ fix error</code> give such a neverending output as the one above (except that the output of the latter, <code>length …</code>, lacks the initial <code>&quot;</code>).</p>
  <p>What am I looking at?</p>
  <hr />
  <p>To be clear, at the moment I still don't understand much out of <a href="https://hackage.haskell.org/package/base-4.16.1.0/docs/Data-Function.html#v:fix" rel="nofollow noreferrer">the docs on hackage</a>. I'm still lost at the first line of it.</p>