HMock-0.4.0.0: A flexible mock framework for testing effectful code.
Safe HaskellNone
LanguageHaskell2010

Test.HMock.Internal.TH

Description

Template Haskell utilities used to implement HMock.

Synopsis

Documentation

unappliedName :: Type -> Maybe Name Source #

Gets the unapplied top-level name from a type application.

tvName :: TyVarBndr -> Name Source #

Fetches the Name of a TyVarBndr.

bindVar :: Name -> TyVarBndr Source #

Creates a TyVarBndr for a plain variable without a kind annotation.

substTypeVar :: Name -> Type -> Type -> Type Source #

Substitutes a Type for all occurrences of the given Name.

substTypeVars :: [(Name, Type)] -> Type -> Type Source #

Makes variable substitutions from the given table.

splitType :: Type -> ([Name], Cxt, [Type], Type) Source #

Splits a function type into a list of bound type vars, context, parameter types, and return value type.

freeTypeVars :: Type -> [Name] Source #

Gets all free type variable Names in the given Type.

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.

constrainVars :: [TypeQ] -> [Name] -> CxtQ Source #

Produces a CxtQ that gives all given variable Names all of the given class Types.

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 Names 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.

resolveInstance :: Name -> [Type] -> Q (Maybe Cxt) Source #

Attempts to produce sufficient constraints for the given Type to be an instance of the given class Name.

resolveInstanceType :: Type -> Q (Maybe Cxt) Source #

Attempts to produce sufficient constraints for the given Type to be a satisfied constraint. The type should be a class applied to its type parameters.

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.