title: Rigid Variable in Applicative instantiation
body: <p>I am getting a compiler error for the Applicative instantiation of <code>Safeness</code>, as follows:</p>
  <pre><code>{-# LANGUAGE InstanceSigs #-}
  
  module Main where
  
  main :: IO ()
  main = pure ()
  
  
  data Safeness a 
      = Unsafe a
      | Safe a
      | VerySafe a
      deriving (Eq, Show)
  
  
  instance Functor Safeness where
      fmap :: (a -&gt; b) -&gt; Safeness a -&gt; Safeness b
      fmap f (Unsafe x) = Unsafe $ f x
      fmap f (Safe x) = Safe $ f x
      fmap f (VerySafe x) = VerySafe $ f x
  
  
  instance Applicative Safeness where
      pure :: a -&gt; Safeness a
      pure x = Safe x
  
      (&lt;*&gt;) :: Safeness (a -&gt; b) -&gt; Safeness a -&gt; Safeness b
      (&lt;*&gt;) (Safe f) (Safe x) = Safe $ f x       
      (&lt;*&gt;) (VerySafe f) (VerySafe x) = VerySafe $ f x    
      (&lt;*&gt;) _ x = x     
  </code></pre>
  <p><strong>Compiler error:</strong></p>
  <pre><code>    * Couldn't match type `a' with `b'
        `a' is a rigid type variable bound by
          the type signature for:
            (&lt;*&gt;) :: forall a b. Safeness (a -&gt; b) -&gt; Safeness a -&gt; Safeness b      
          at C:\practise\app\Main.hs:27:14-58       
        `b' is a rigid type variable bound by
          the type signature for:
            (&lt;*&gt;) :: forall a b. Safeness (a -&gt; b) -&gt; Safeness a -&gt; Safeness b      
          at C:\practise\app\Main.hs:27:14-58       
        Expected type: Safeness b
          Actual type: Safeness a
      * In the expression: x
        In an equation for `&lt;*&gt;': (&lt;*&gt;) _ x = x
        In the instance declaration for `Applicative Safeness'
      * Relevant bindings include
          x :: Safeness a
            (bound at C:\practise\app\Main.hs:30:13)
          (&lt;*&gt;) :: Safeness (a -&gt; b) -&gt; Safeness a -&gt; Safeness b
            (bound at C:\practise\app\Main.hs:28:5) 
     |
  30 |     (&lt;*&gt;) _ x = x       
     |   
  </code></pre>
  <p>I understand that <code>b</code> doesn't have to be the same as <code>a</code>, but it could; and I am always forcing it to be the same in a certain case.  What is wrong with that, and how else can I code this for the intended functionality?</p>