title: Haskell: pattern matching on Num types
body: <p>Why can't Haskell perform pattern matching on <code>Num</code> types, without us specifying <code>Eq</code> as a type class?</p>
  
  <p>For instance:</p>
  
  <pre><code>h :: Num a =&gt; a -&gt; a
  h 0 = -1
  h x = x + 1
  </code></pre>
  
  <p>When compiling this function, <code>ghci</code> complains:</p>
  
  <pre><code>    * Could not deduce (Eq a) arising from the literal `0'
        from the context: Num a
          bound by the type signature for:
                     h :: forall a. Num a =&gt; a -&gt; a
          at functions.hs:9:1-20
        Possible fix:
          add (Eq a) to the context of
            the type signature for:
              h :: forall a. Num a =&gt; a -&gt; a
      * In the pattern: 0
        In an equation for `h': h 0 = - 1
     |
  10 | h 0 = -1
     |   ^
  </code></pre>
  
  <p>Changing the function definition as following compiles and runs perfectly:</p>
  
  <pre><code>h :: (Num a, Eq a) =&gt; a -&gt; a
  h 0 = -1
  h x = x + 1
  
  *Main&gt; h 0
  -1
  *Main&gt;
  </code></pre>