futhark-0.22.4: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Futhark.TypeChecker.Types

Contents

Description

Type checker building blocks that do not involve unification.

Synopsis

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 subuniqueOf y is true if x is not less unique than y.

returnType :: Aliasing -> PatType -> Diet -> PatType -> PatType Source #

returnType appres ret_type arg_diet arg_type gives result of applying an argument the given types to a function with the given return type, consuming the argument with the given diet.

addAliasesFromType :: PatType -> PatType -> PatType Source #

The two types are assumed to be structurally equal, but not necessarily regarding sizes. Combines aliases.

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.

data Subst t Source #

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

Constructors

Subst [TypeParam] t 
PrimSubst 
SizeSubst Size 

Instances

Instances details
Functor Subst Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Types

Methods

fmap :: (a -> b) -> Subst a -> Subst b #

(<$) :: a -> Subst b -> Subst a #

Show t => Show (Subst t) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Types

Methods

showsPrec :: Int -> Subst t -> ShowS #

show :: Subst t -> String #

showList :: [Subst t] -> ShowS #

Pretty t => Pretty (Subst t) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Types

Methods

pretty :: Subst t -> Doc ann #

prettyList :: [Subst t] -> Doc ann #

substFromAbbr :: TypeBinding -> Subst StructRetType Source #

Create a type substitution corresponding to a type binding.

type TypeSubs = VName -> Maybe (Subst StructRetType) Source #

Substitutions to apply in a type.

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 #

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.