4</code></pre><h6 id="io"><a href="#io" class="anchor"></a>IO</h6><p>A good introduction on why monads are used for <code>IO</code> is to consider how javascript handles effects: using callbacks. This is called <a href="https://en.m.wikipedia.org/wiki/Continuation-passing_style">continuation passing style</a>.</p><p>A motivation for developing promises was to avoid callback hell:</p><pre><code class="ml">doSomeEffect(cb =&gt; {
  // do more stuff
  doSomeOtherEffect(cb =&gt; {
    // do more stuff
    doYet