title: How can I derive a Data instance for a GADT in Haskell?
body: <p>I have a GADT which is only ever used with two different parameters, ForwardPossible and ():</p>
  
  <pre><code>-- | Used when a forward definition is possible.
  data ForwardPossible = ForwardPossible deriving (Eq, Ord, Typeable, Data, Show)
  
  -- | GADT which accepts forward definitions if parameter is ForwardPossible.
  data OrForward t forward where
    OFKnown :: t -&gt; OrForward t forward
    OFForward :: NamespaceID -&gt; SrcSpan -&gt; BS.ByteString -&gt; OrForward t ForwardPossible
  
  deriving instance Eq t =&gt; Eq (OrForward t forward)
  deriving instance Ord t =&gt; Ord (OrForward t forward)
  deriving instance Typeable2 OrForward
  deriving instance Show t =&gt; Show (OrForward t forward)
  </code></pre>
  
  <p>I would like to derive enough Data.Data instances to cover both OrForward t () and OrForward t ForwardPossible. I don't think a general (Data t, Data forward) => OrForward t forward instance is possible unless it universally ignores OFForward, but either overlapping instances for Data t => OrForward t ForwardPossible and (Data t, Data forward) => OrForward t forward instances could be a solution if there is a way to make ghc derive those instances.</p>
  
  <p>I have tried defining:</p>
  
  <pre><code>deriving instance Data t =&gt; Data (OrForward t ())
  deriving instance Data t =&gt; Data (OrForward t ForwardPossible)
  </code></pre>
  
  <p>but then ghc gives me an error like this:</p>
  
  <pre><code>Duplicate type signature:
    Structure.hs:53:1-70: $tOrForward :: DataType
    Structure.hs:52:1-49: $tOrForward :: DataType
  </code></pre>