我有一个只能用两个不同的参数,ForwardPossible和()使用的GADT:
-- | 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 -> OrForward t forward
OFForward :: NamespaceID -> SrcSpan -> BS.ByteString -> OrForward t ForwardPossible
deriving instance Eq t => Eq (OrForward t forward)
deriving instance Ord t => Ord (OrForward t forward)
deriving instance Typeable2 OrForward
deriving instance Show t => Show (OrForward t forward)
我想获得足够的Data.Data实例涵盖OrForward T()和OrForward牛逼ForwardPossible。 我不认为一般的(数据T,数据转发)=> OrForward吨向前实例是可能的,除非它普遍忽略OFForward,但无论是对重叠实例数据T => OrForward吨ForwardPossible和(数据T,数据转发)=> OrForward T个前向实例可能是一个解决方案,如果有一种方法,使GHC获得这些实例。
我曾尝试定义:
deriving instance Data t => Data (OrForward t ())
deriving instance Data t => Data (OrForward t ForwardPossible)
但随后GHC给了我这样的错误:
Duplicate type signature:
Structure.hs:53:1-70: $tOrForward :: DataType
Structure.hs:52:1-49: $tOrForward :: DataType