Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This works because of operator precedence. The function application operator, juxtaposition or <code></code> (the space), has the highest precedence, so <code>take 34 fibseq |&gt; filter even</code> parses as <code>((take 34) fibseq) |&gt; (filter even)</code>, which is equivalent to <code>(filter even) ((take 34) fibseq)</code>; since function application is left-associative, this is then equivalent to <code>filter even (take 34 fibseq)</code>.</p> <p>In general, any binary operator can be given a precedence with a fixity declaration, such as</p> <pre><code>infixl 0 |&gt; infixr 9 . </code></pre> <p>The <code>l</code> or <code>r</code> says whether the operation is left- or right-associative (that is, whether <code>a • b • c</code> groups as <code>(a • b) • c</code> or <code>a • (b • c)</code>); the number—an integer between 0 and 9—specifies the precedence level. Higher numbers mean higher precedence (with application having an effective precedence of ∞); for instance, <code>*</code> and <code>/</code> have precedence 7, and <code>+</code> and <code>-</code> have precedence 6. To check the precedence of an operator in ghci, just type <code>:info $</code> (or whichever operator) at the prompt.</p> <p>And just as a note: your code will work, but it's not how I would typically write it. If you're curious, in Haskell, I would write that code with the <code>$</code> operator, which just performs function application but is low precedence: <code>filter even $ take 34 fibseq</code>. If I had more functions to apply, I would use the composition operator: <code>fun1 arg1 . fun2 . fun3 arg2 arg3 . filter even $ take 34 fibseq</code>. It reads the other way, but it's what you typically find in Haskell.</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