Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Template Haskell script to promote a type family to first class.
Synopsis
- fcfify :: Name -> Q [Dec]
- fcfifySkip :: Name -> Q [Dec]
- fcfify' :: Name -> Q [Dec]
- promoteFamily :: Name -> Q (Type, Int)
- promoteNDFamily :: Name -> Q (Type, Int)
- familyName :: Name -> Type
- applyFamily :: Name -> [Q Type] -> Q Type
- consTuple :: [Type] -> Type
- paramsProxy :: Name -> Q Type
- isTypeFamily :: Name -> Q Bool
- isTypeSynonym :: Name -> Q Bool
- isTypeFamilyOrSynonym :: Name -> Q Bool
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.
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
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.