data-constructors-0.1.0.0: Generically compare data by their constructors

Safe HaskellNone
LanguageHaskell2010

Data.Constructors.TH

Synopsis

Documentation

class EqC a where Source #

Methods

eqConstr :: a -> a -> Bool Source #

Compare the outermost constructor for a datatype. Instances should satisfy eqConstr (C a) (K b) = True iff C=K

eqConstr :: Data a => a -> a -> Bool Source #

Compare the outermost constructor for a datatype. Instances should satisfy eqConstr (C a) (K b) = True iff C=K

deriveEqC :: Name -> DecsQ Source #

Derive an instance of EqC for any simple type For example, deriveEqC ''Either will generate:

instance EqC (Either a b) where
  eqConstr Left{}  Left{}  = True
  eqConstr Right{} Right{} = True
  eqConstr _       _       = False