Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Type checker building blocks that do not involve unification.
Synopsis
- checkTypeExp :: (MonadTypeChecker m, Pretty df) => (df -> m Exp) -> TypeExp df VName -> m (TypeExp Exp VName, [VName], ResRetType, Liftedness)
- renameRetType :: MonadTypeChecker m => ResRetType -> m ResRetType
- typeParamToArg :: TypeParam -> StructTypeArg
- data Subst t
- substFromAbbr :: TypeBinding -> Subst StructRetType
- type TypeSubs = VName -> Maybe (Subst StructRetType)
- class Substitutable a where
- applySubst :: TypeSubs -> a -> a
- substTypesAny :: Monoid u => (VName -> Maybe (Subst (RetTypeBase Size u))) -> TypeBase Size u -> TypeBase Size u
- mustBeExplicitInType :: StructType -> Set VName
- mustBeExplicitInBinding :: StructType -> Set VName
- determineSizeWitnesses :: StructType -> (Set VName, Set VName)
Documentation
checkTypeExp :: (MonadTypeChecker m, Pretty df) => (df -> m Exp) -> TypeExp df VName -> m (TypeExp Exp VName, [VName], ResRetType, Liftedness) Source #
Check a type expression, producing:
- The checked expression.
- Size variables for any anonymous sizes in the expression.
- The elaborated type.
- The liftedness of the type.
renameRetType :: MonadTypeChecker m => ResRetType -> m ResRetType Source #
Ensure that the dimensions of the RetType are unique by generating new names for them. This is to avoid name capture.
typeParamToArg :: TypeParam -> StructTypeArg Source #
Construct a type argument corresponding to a type parameter.
A type substitution may be a substitution or a yet-unknown substitution (but which is certainly an overloaded primitive type!).
substFromAbbr :: TypeBinding -> Subst StructRetType Source #
Create a type substitution corresponding to a type binding.
class Substitutable a where Source #
Class of types which allow for substitution of types with no annotations for type variable names.
applySubst :: TypeSubs -> a -> a Source #
Instances
substTypesAny :: Monoid u => (VName -> Maybe (Subst (RetTypeBase Size u))) -> TypeBase Size u -> TypeBase Size u Source #
Perform substitutions, from type names to types, on a type. Works regardless of what shape and uniqueness information is attached to the type.
Witnesses
mustBeExplicitInType :: StructType -> Set VName Source #
Figure out which of the sizes in a parameter type must be passed explicitly, because their first use is as something else than just an array dimension.
mustBeExplicitInBinding :: StructType -> Set VName Source #
Figure out which of the sizes in a binding type must be passed explicitly, because their first use is as something else than just an array dimension.
determineSizeWitnesses :: StructType -> (Set VName, Set VName) Source #
Determine which of the sizes in a type are used as sizes outside of functions in the type, and which are not. The former are said to be "witnessed" by this type, while the latter are not. In practice, the latter means that the actual sizes must come from somewhere else.