Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This comes from a culture of having small <em>"kernel"</em> expression-oriented languages. Haskell grows from Lisp's roots (i.e. <a href="https://en.wikipedia.org/wiki/Lambda_calculus" rel="nofollow noreferrer">lambda calculus</a> and <a href="http://en.wikipedia.org/wiki/Combinatory_logic" rel="nofollow noreferrer">combinatory logic</a>); it's basically Lisp <em>plus</em> syntax <em>plus</em> explicit data type definitions <em>plus</em> pattern matching <em>minus</em> mutation <em>plus</em> lazy evaluation (lazy evaluation was itself first described in Lisp AFAIK; i.e. in the 70-s). </p> <p>Lisp-like languages are expression-oriented, i.e. everything is an expression, and a language's semantics is given as a set of reduction rules, turning more complex expressions into simpler ones, and ultimately into "values". </p> <p>Equations are not expressions. Several equations could be somehow mashed into one expression; you'd have to introduce some syntax for that; <code>case</code> is that syntax.</p> <p>Rich syntax of Haskell gets translated into smaller "core" language, that has <code>case</code> as one of its basic building blocks. <code>case</code> has to be a basic construct, because pattern-matching in Haskell is made to be such a basic, core feature of the language. </p> <hr> <p>To your new question, yes you can, by introducing auxiliary functions as Luis Casillas shows <a href="https://stackoverflow.com/a/20767809/849891">in his answer</a>, or with the use of pattern guards, so his example becomes:</p> <pre><code>foo x y | (Meh o p) &lt;- z = baz y p o | (Gah t q) &lt;- z = quux x t q where z = bar x </code></pre>
 

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