Is there any guarantee about the evaluation order within a pattern match?
<p>The following</p>

<pre><code>(&amp;&amp;) :: Bool -&gt; Bool -&gt; Bool
False &amp;&amp; _ = False
True &amp;&amp; False = False
True &amp;&amp; True = True
</code></pre>

<p>has the desired short-circuit property <code>False &amp;&amp; undefined ≡ False</code>. The first clause, which is non-strict in the right argument, is guaranteed to be checked before anything else is tried.</p>

<p>Apparently, it still works if I change the order and even uncurry the function</p>

<pre><code>both :: (Bool,Bool) -&gt; Bool
both (True,False) = False
both (True, True) = True
both (False, _) = False

Prelude&gt; both (False, undefined)
False
</code></pre>

<p>but is this actually guaranteed by the standard? Unlike with the order of clauses, the order of evaluation of the patterns is not so clear here. Can I actually be sure that matching <code>(True,False)</code> will be aborted as soon as <code>(False,_)</code> is determined, before the snd element is evaluated at all?</p>