title: Haskell - Using a constant in pattern matching
body: <p>Let's say I have the following code (text in <code>&lt;&gt;</code> is a shorthand, not actually part of the code):</p>
  
  <pre><code>data A = &lt;something&gt;
  defaultA :: A
  defaultA = &lt;Really complicated expression of type A&gt;
  </code></pre>
  
  <p>Now I want to have a function pattern match on <code>defaultA</code>, like this:</p>
  
  <pre><code>f defaultA = &lt;case 1&gt;
  f _ = &lt;case 2&gt;
  </code></pre>
  
  <p>However, <code>defaultA</code> in the first line becomes a new variable, not a condition that means the parameter will equal <code>defaultA</code>. The best way I know to achieve something like what I want is:</p>
  
  <pre><code>f x | x == defaultA = &lt;case 1&gt;
  f _ = &lt;case 2&gt;
  </code></pre>
  
  <p>Does anyone know a better way?</p>