Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>0=1</code> is just a pattern binding. </p> <p><a href="http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-620004" rel="nofollow">Haskell 2010 Language Report describes</a></p> <pre><code> 4.4.3 Function and Pattern Bindings decl → (funlhs | pat) rhs funlhs → var apat { apat } | pat varop pat | ( funlhs ) apat { apat } rhs → = exp [where decls] | gdrhs [where decls] gdrhs → guards = exp [gdrhs] guards → | guard1, …, guardn (n ≥ 1) guard → pat </pre> <blockquote> <p>We distinguish two cases within this syntax: <strong>a pattern binding</strong> occurs when the left hand side is a <strong>pat</strong>; otherwise, the binding is called <strong>a function binding</strong>. Either binding may appear at the top-level of a module or within a where or let construct. </p> </blockquote> <p>Patterns have this syntax:</p> <pre><code> pat → lpat qconop pat (infix constructor) | lpat lpat → apat | - (integer | float) (negative literal) | gcon apat1 … apatk (arity gcon = k, k ≥ 1) apat → var [ @ apat] (as pattern) | gcon (arity gcon = 0) | qcon { fpat1 , … , fpatk } (labeled pattern, k ≥ 0) | literal | _ (wildcard) | ( pat ) (parenthesized pattern) | ( pat1 , … , patk ) (tuple pattern, k ≥ 2) | [ pat1 , … , patk ] (list pattern, k ≥ 1) | ~ apat (irrefutable pattern) fpat → qvar = pat </code></pre> <p>Language Report also states</p> <blockquote> <p>A pattern binding binds variables to values. A simple pattern binding has form p = e. The pattern p is matched “lazily” as an irrefutable pattern, as if there were an implicit ~ in front of it.</p> </blockquote> <p>So, <code>0</code> in <code>0=1</code> is just a pattern. In essence, <code>0=1</code> and <code>x=1</code> are the same thing. They are both pattern bindings.<br/> The pattern is irrefutable, <code>0=1</code> does not fail, thus no error occurred and nothing happened.</p> <p>If we have the following top level declaration. Something will happen.</p> <pre><code>x@(Just y) | z /= Nothing = Just 1 where z = Just 0 </code></pre> <p><code>x</code> and <code>y</code> are binding to <code>Just 1</code> and 1</code>.</p>
 

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