th-expand-syns-0.4.6.0: Expands type synonyms in Template Haskell ASTs

Safe HaskellNone
LanguageHaskell98

Language.Haskell.TH.ExpandSyns

Contents

Synopsis

Expand synonyms

expandSyns :: Type -> Q Type Source #

Calls expandSynsWith with the default settings.

expandSynsWith :: SynonymExpansionSettings -> Type -> Q Type Source #

Expands all type synonyms in the given type. Type families currently won't be expanded (but will be passed through).

noWarnTypeFamilies :: SynonymExpansionSettings Source #

Suppresses the warning that type families are unsupported.

Misc utilities

substInType :: (Name, Type) -> Type -> Type Source #

Capture-free substitution

substInCon :: (Name, Type) -> Con -> Con Source #

Capture-free substitution

evades :: Data t => [Name] -> t -> [Name] Source #

Make a list of names (based on the first arg) such that every name in the result is distinct from every name in the second arg, and from the other results

evade :: Data d => Name -> d -> Name Source #

Make a name (based on the first arg) that's distinct from every name in the second arg

Example why this is necessary:

type E x = forall y. Either x y

... expandSyns [t| forall y. y -> E y |]

The example as given may actually work correctly without any special capture-avoidance depending on how GHC handles the ys, but in any case, the input type to expandSyns may be an explicit AST using mkName to ensure a collision.