Safe Haskell | None |
---|---|
Language | Haskell2010 |
Template Haskell utilities used to implement HMock.
Synopsis
- unappliedName :: Type -> Maybe Name
- tvName :: TyVarBndr -> Name
- bindVar :: Name -> TyVarBndr
- substTypeVar :: Name -> Type -> Type -> Type
- substTypeVars :: [(Name, Type)] -> Type -> Type
- splitType :: Type -> ([Name], Cxt, [Type])
- freeTypeVars :: Type -> [Name]
- relevantContext :: Type -> ([Name], Cxt) -> ([Name], Cxt)
- constrainVars :: [TypeQ] -> [Name] -> CxtQ
- unifyTypes :: Type -> Type -> Q (Maybe [(Name, Type)])
- removeModNames :: Data a => a -> a
- hasPolyType :: Type -> Bool
- hasNestedPolyType :: Type -> Bool
- resolveInstance :: Name -> Type -> Q (Maybe Cxt)
- simplifyContext :: Cxt -> Q (Maybe Cxt)
- localizeMember :: Type -> Name -> Type -> Q Type
Documentation
unappliedName :: Type -> Maybe Name Source #
Gets the unapplied top-level name from a type application.
bindVar :: Name -> TyVarBndr Source #
Creates a TyVarBndr
for a plain variable without a kind annotation.
substTypeVars :: [(Name, Type)] -> Type -> Type Source #
Makes variable substitutions from the given table.
splitType :: Type -> ([Name], Cxt, [Type]) Source #
Splits a function type into a list of bound type vars, context, and parameters and return value. The return value is the last element of the list.
relevantContext :: Type -> ([Name], Cxt) -> ([Name], Cxt) Source #
Culls the given binders and constraints to choose only those that apply to free variables in the given type.
unifyTypes :: Type -> Type -> Q (Maybe [(Name, Type)]) Source #
Attempts to unify the given types by constructing a table of substitutions for the variables of the left type that obtain the right one.
removeModNames :: Data a => a -> a Source #
Removes all module names from Name
s in the given value, so that it will
pretty-print more cleanly.
hasPolyType :: Type -> Bool Source #
Determines if this is a polytype, including top-level quantification.
hasNestedPolyType :: Type -> Bool Source #
Determines if there is a polytype nested anywhere in the given type. Top-level quantification doesn't count.
simplifyContext :: Cxt -> Q (Maybe Cxt) Source #
Simplifies a context with complex types (requiring FlexibleContexts) to try to obtain one with all constraints applied to variables.
localizeMember :: Type -> Name -> Type -> Q Type Source #
Remove instance context from a method.
Some GHC versions report class members including the instance context (for
example, show :: Show a => a -> String
, instead of show :: a -> String
).
This looks for the instance context, and substitutes if needed to eliminate
it.