title: On a Functor instance declaration
body: <p>This loads without error:</p>
  
  <pre><code>data Const c a = Const c
  
  instance Functor (Const c) where
      fmap _ (Const v) = Const v
  </code></pre>
  
  <p>...but this</p>
  
  <pre><code>data Const' c a = Const' c
  
  instance Functor (Const' c) where
      fmap _ cv = cv
  </code></pre>
  
  <p>...fails with:</p>
  
  <pre><code>    Couldn't match type `a' with `b'
        `a' is a rigid type variable bound by
            the type signature for fmap :: (a -&gt; b) -&gt; Const' c a -&gt; Const' c b
            at test.hs:4:5
        `b' is a rigid type variable bound by
            the type signature for fmap :: (a -&gt; b) -&gt; Const' c a -&gt; Const' c b
            at test.hs:4:5
      Expected type: Const' c b
        Actual type: Const' c a
      In the expression: cv
      In an equation for `fmap': fmap _ cv = cv
      In the instance declaration for `Functor (Const' c)'
  </code></pre>
  
  <p>I don't understand the error.  Why can't the compiler infer that the type of <code>cv</code> is <code>Const' c</code>?  What else could it be, given the rest of the declaration, and the definition of <code>fmap</code>?</p>