title: Is this type-class constraint necessary or redundant?
body: <p>The following code successfully compiles, but gets a warning when using GHC 9.2.3 with <code>-Wredundant-constraints</code>:</p>
  <pre><code>{-# LANGUAGE UndecidableInstances, FlexibleInstances #-}
  
  class Functor f =&gt; C f where c :: f Int
  
  instance (Functor f, Applicative f) =&gt; C f where c = pure 42
  </code></pre>
  <p>The resulting warning:</p>
  <pre><code>test.hs:5:10: warning: [-Wredundant-constraints]
      • Redundant constraint: Functor f
      • In the instance declaration for ‘C f’
    |
  5 | instance (Functor f, Applicative f) =&gt; C f where c = pure 42
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  </code></pre>
  <p>However, if I remove this constraint, the code no longer type checks:</p>
  <pre><code>test.hs:5:10: error:
      • Could not deduce (Functor f)
          arising from the superclasses of an instance declaration
        from the context: Applicative f
          bound by the instance declaration at test.hs:5:10-29
        Possible fix:
          add (Functor f) to the context of the instance declaration
      • In the instance declaration for ‘C f’
    |
  5 | instance Applicative f =&gt; C f where c = pure 42
    |          ^^^^^^^^^^^^^^^^^^^^
  </code></pre>
  <p>This confuses me.</p>
  <p>Is this constraint truly redundant, or is it in fact necessary?</p>
  <p>Intuitively I would say that it is redundant, as it is implied by <code>Applicative f</code> already! But GHC begs to differ so I'm unsure.</p>