kind-generics-th-0.2.3.1: Template Haskell support for generating `GenericK` instances
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

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

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.

preDeriveGenericK ''MyT1
preDeriveGenericK ''MyT2
preDeriveGenericK ''MyT3
postDeriveGenericK

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.