fcf-family-0.2.0.0: Family of families: featherweight defunctionalization
Safe HaskellSafe-Inferred
LanguageHaskell2010

Fcf.Family.TH

Description

Template Haskell script to promote a type family to first class.

Synopsis

Generate boilerplate

fcfify :: Name -> Q [Dec] Source #

Generate the boilerplate needed to promote a type family to first class.

Required extensions:

  • DataKinds
  • PolyKinds
  • TypeFamilies

If fcfify is called more than once with the same Name in the same module, only the first invocation generates declarations; subsequent declarations return the empty list, avoiding duplicate declarations in the current module.

For a stateless variant, use fcfify'.

See Fcf.Family for details on the encoding.

fcfifySkip :: Name -> Q [Dec] Source #

Mark a type family as already fcifified.

fcfify' :: Name -> Q [Dec] Source #

Generate the boilerplate needed to promote a type family to first class.

Unlike fcfify, this always returns the same declarations for the same named type.

Using promoted families

promoteFamily :: Name -> Q (Type, Int) Source #

Promote a fcfified family, returning its partially applied Family and its arity. The result can be applied to a consTuple of the appropriate size,

promoteNDFamily :: Name -> Q (Type, Int) Source #

Promote a fcfified family, returning its partially applied Family and its arity. The result can be applied to a consTuple of the appropriate size,

familyName :: Name -> Type Source #

Get the quoted fcf Name of an existing type family.

applyFamily :: Name -> [Q Type] -> Q Type Source #

Apply a promoted family.

If there are more arguments than the arity of the family (as returned by promoteFamily), they are split and applied properly: the family's main arguments are collected in a consTuple and the rest are applied with AppT.

If there are fewer arguments than the arity, the result is nonsense.

consTuple :: [Type] -> Type Source #

Construct a tuple suitable for a Family argument.

Predicates

isTypeFamily :: Name -> Q Bool Source #

True if it is a type family (open or closed).

isTypeSynonym :: Name -> Q Bool Source #

True if it is a type synonym.

isTypeFamilyOrSynonym :: Name -> Q Bool Source #

True if it is a type family or synonym.