| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Language.Futhark.TypeChecker.Types
Description
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
- unifyTypesU :: (Monoid als, ArrayDim dim) => (Uniqueness -> Uniqueness -> Maybe Uniqueness) -> TypeBase dim als -> TypeBase dim als -> Maybe (TypeBase dim als)
- subtypeOf :: TypeBase () () -> TypeBase () () -> Bool
- subuniqueOf :: Uniqueness -> Uniqueness -> Bool
- checkForDuplicateNames :: MonadTypeChecker m => [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 (DimDecl VName) as))) -> TypeBase (DimDecl VName) as -> TypeBase (DimDecl VName) as
Documentation
checkTypeExp :: MonadTypeChecker m => TypeExp Name -> m (TypeExp VName, [VName], StructRetType, Liftedness) Source #
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.
unifyTypesU :: (Monoid als, ArrayDim dim) => (Uniqueness -> Uniqueness -> Maybe Uniqueness) -> TypeBase dim als -> TypeBase dim als -> Maybe (TypeBase dim als) Source #
unifyTypes uf t1 t2 attempts to unify t1 and t2. If
unification cannot happen, Nothing is returned, otherwise a type
that combines the aliasing of t1 and t2 is returned.
Uniqueness is unified with uf. Assumes sizes already match, and
always picks the size of the leftmost type.
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.
checkForDuplicateNames :: MonadTypeChecker m => [UncheckedPat] -> m () Source #
Check for duplication of names inside a pattern group. Produces a description of all names used in the pattern 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.
Methods
applySubst :: TypeSubs -> a -> a Source #
Instances
| Substitutable Pat Source # | |
Defined in Language.Futhark.TypeChecker.Types | |
| Substitutable d => Substitutable (ShapeDecl d) Source # | |
Defined in Language.Futhark.TypeChecker.Types | |
| Substitutable (DimDecl VName) Source # | |
Defined in Language.Futhark.TypeChecker.Types | |
| Substitutable (TypeBase (DimDecl VName) ()) Source # | |
| Substitutable (TypeBase (DimDecl VName) Aliasing) Source # | |
| Substitutable (RetTypeBase (DimDecl VName) ()) Source # | |
Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> RetTypeBase (DimDecl VName) () -> RetTypeBase (DimDecl VName) () Source # | |
| Substitutable (RetTypeBase (DimDecl VName) Aliasing) Source # | |
Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> RetTypeBase (DimDecl VName) Aliasing -> RetTypeBase (DimDecl VName) Aliasing Source # | |
substTypesAny :: Monoid as => (VName -> Maybe (Subst (RetTypeBase (DimDecl VName) as))) -> TypeBase (DimDecl VName) as -> TypeBase (DimDecl VName) 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.