Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Write short and concise contexts based on generics.
Instead of writing boiler-plate standalone deriving clauses in the form of
deriving instance [Various Eq Constraints Here] => Instance Eq MyType
You can use
deriving instance Constraints MyType Eq => Eq MyType
And with the TemplateHaskell
helpers makeDeriving
and others,
your declarations can be even more concise.
Synopsis
- type Constraints t c = Constraints' (Rep t) c
- makeDeriving :: Name -> Name -> DecsQ
- makeDerivings :: [Name] -> [Name] -> DecsQ
- makeInstance :: Name -> Name -> DecsQ
- makeInstances :: [Name] -> [Name] -> DecsQ
Documentation
type Constraints t c = Constraints' (Rep t) c Source #
Constraints
is a constraint type synonym, containing the constraint
requirements for an instance for t
of class c
.
It requires an instance of class c
for each component of t
.
Useful for the writing the context of StandaloneDeriving
clauses:
deriving instance Constraints MyType Eq => Eq MyType
Template Haskell helpers
makeDeriving :: Name -> Name -> DecsQ Source #
TemplateHaskell
generation of a standalone deriving declaration.
makeDeriving ''Ord ''MyType
Generates:
deriving instance Constraints MyType Ord => Ord MyType
makeDerivings :: [Name] -> [Name] -> DecsQ Source #
TemplateHaskell
generation of multiple standalone deriving declarations.
makeDerivings [''Eq, ''Ord, ''Show] [''MyType, ''MyOtherType]
Generates the deriving declarations for all given classes and types.