Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Type checker building blocks that do not involve unification.
Synopsis
- checkTypeExp :: MonadTypeChecker m => TypeExp Name -> m (TypeExp VName, [VName], StructRetType, Liftedness)
- renameRetType :: MonadTypeChecker m => StructRetType -> m StructRetType
- subtypeOf :: TypeBase () () -> TypeBase () () -> Bool
- subuniqueOf :: Uniqueness -> Uniqueness -> Bool
- addAliasesFromType :: StructType -> PatType -> PatType
- checkForDuplicateNames :: MonadTypeChecker m => [UncheckedTypeParam] -> [UncheckedPat] -> m ()
- checkTypeParams :: MonadTypeChecker m => [TypeParamBase Name] -> ([TypeParamBase VName] -> m a) -> m a
- 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 as => (VName -> Maybe (Subst (RetTypeBase Size as))) -> TypeBase Size as -> TypeBase Size as
- mustBeExplicitInType :: StructType -> Set VName
- mustBeExplicitInBinding :: StructType -> Set VName
- determineSizeWitnesses :: StructType -> (Set VName, Set VName)
Documentation
checkTypeExp :: MonadTypeChecker m => TypeExp Name -> m (TypeExp VName, [VName], StructRetType, 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 => StructRetType -> m StructRetType Source #
Ensure that the dimensions of the RetType are unique by generating new names for them. This is to avoid name capture.
subtypeOf :: TypeBase () () -> TypeBase () () -> Bool Source #
x `subtypeOf` y
is true if x
is a subtype of y
(or equal
to y
), meaning x
is valid whenever y
is. Ignores sizes.
Mostly used for checking uniqueness.
subuniqueOf :: Uniqueness -> Uniqueness -> Bool Source #
x
is true if subuniqueOf
yx
is not less unique than y
.
addAliasesFromType :: StructType -> PatType -> PatType Source #
The two types are assumed to be structurally equal, but not necessarily regarding sizes. Adds aliases from the latter to the former.
checkForDuplicateNames :: MonadTypeChecker m => [UncheckedTypeParam] -> [UncheckedPat] -> m () Source #
Check for duplication of names inside a binding group.
checkTypeParams :: MonadTypeChecker m => [TypeParamBase Name] -> ([TypeParamBase VName] -> m a) -> m a Source #
checkTypeParams ps m
checks the type parameters ps
, then
invokes the continuation m
with the checked parameters, while
extending the monadic name map with ps
.
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!). The latter is used to remove aliases from types that are yet-unknown but that we know cannot carry aliases (see issue #682).
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
Substitutable Pat Source # | |
Defined in Language.Futhark.TypeChecker.Types | |
Substitutable Size Source # | |
Defined in Language.Futhark.TypeChecker.Types | |
Substitutable d => Substitutable (Shape d) Source # | |
Defined in Language.Futhark.TypeChecker.Types | |
Substitutable (RetTypeBase Size Aliasing) Source # | |
Defined in Language.Futhark.TypeChecker.Types applySubst :: TypeSubs -> RetTypeBase Size Aliasing -> RetTypeBase Size Aliasing Source # | |
Substitutable (RetTypeBase Size ()) Source # | |
Defined in Language.Futhark.TypeChecker.Types applySubst :: TypeSubs -> RetTypeBase Size () -> RetTypeBase Size () Source # | |
Substitutable (TypeBase Size Aliasing) Source # | |
Substitutable (TypeBase Size ()) Source # | |
Defined in Language.Futhark.TypeChecker.Types |
substTypesAny :: Monoid as => (VName -> Maybe (Subst (RetTypeBase Size as))) -> TypeBase Size as -> TypeBase Size as 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.