| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Generics.Kind.TH
Description
Main module of kind-generics-th.
Please refer to the README file for documentation on how to use this package.
Synopsis
- deriveGenericK :: Name -> Q [Dec]
- deriveGenericKQuiet :: Name -> Q [Dec]
- preDeriveGenericK :: Name -> Q [Dec]
- postDeriveGenericK :: Q [Dec]
Documentation
deriveGenericK :: Name -> Q [Dec] Source #
Given the Name of a data type (or, the Name of a constructor belonging
to a data type), generate GenericK instances for that data type. You will
likely need to enable most of these language extensions in order for GHC to
accept the generated code:
DataKinds
EmptyCase(if using an empty data type)FlexibleInstances
MultiParamTypeClasses
PolyKinds(if using a poly-kinded data type)TemplateHaskell
TypeFamilies
If the data type uses type families, deriveGenericK warns that it
skips the GenericK instances that require special support for it
- Use
preDeriveGenericKandpostDeriveGenericKto support type families. - Use
deriveGenericKQuietto silence the warnings.
deriveGenericKQuiet :: Name -> Q [Dec] Source #
Variant of deriveGenericK that doesn't emit warnings.
preDeriveGenericK :: Name -> Q [Dec] Source #
Generate GenericK instances for data types that may mention
type families.
This preDeriveGenericK is to be used in combination with
postDeriveGenericK. These two functions let us stage the compilation of
the generated type instances, because GHC cannot compile them in a single
group.
preDeriveGenericKgenerates type instances to promote type families that occur in the given data types (usingfcfify; see fcf-family). TheGenericKinstances are not produced at this stage, they are accumulated in some internal global queue.postDeriveGenericKproduces all of the accumulatedGenericKinstances. It should be called in a slice separated frompreDeriveGenericK. Multiple calls topreDeriveGenericKmay precedepostDeriveGenericK.
preDeriveGenericK''MyT1preDeriveGenericK''MyT2preDeriveGenericK''MyT3postDeriveGenericK
You will need to enable the extensions UndecidableInstances and PolyKinds
(even if your data types are not poly-kinded)
in addition to those mentioned in the documentation of deriveGenericK.
postDeriveGenericK :: Q [Dec] Source #
See preDeriveGenericK.