Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In a <code>let</code> binding, the expression can have any type, and all you're doing is giving it a name (or pattern matching on its internal structure).</p> <p>In the <code>&lt;-</code> version, the expression must have type <code>m a</code>, where <code>m</code> is whatever monad the <code>do</code> block is in. So in the <code>IO</code> monad, for instance, bindings of this form must have some value of type <code>IO a</code> on the right-hand side. The <code>a</code> part (inside the monadic value) is what is bound to the pattern on the left-hand side. This lets you extract the "contents" of the monad within the limited scope of the <code>do</code> block.</p> <p>The <code>do</code> notation is, as you may have read, just syntactic sugar over the monadic binding operators (<code>&gt;&gt;=</code> and <code>&gt;&gt;</code>). <code>x &lt;- expression</code> de-sugars to <code>expression &gt;&gt;= \x -&gt;</code> and <code>expression</code> (by itself, without the <code>&lt;-</code>) de-sugars to <code>expression &gt;&gt;</code>. This just gives a more convenient syntax for defining long chains of monadic computations, which otherwise tend to build up a rather impressive mass of nested lambdas.</p> <p><code>let</code> bindings don't de-sugar at all, really. The only difference between <code>let</code> in a <code>do</code> block and <code>let</code> outside of a <code>do</code> block is that the <code>do</code> version doesn't require the <code>in</code> keyword to follow it; the names it binds are implicitly in scope for the rest of the <code>do</code> block.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload