futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | None
Language | GHC2021

Language.Futhark.TypeChecker.Types

Contents

- Witnesses

Description

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
  - = Subst [TypeParam] t
  - | ExpSubst Exp
- 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.

data Subst t Source #

A type substitution may be a substitution or a yet-unknown substitution (but which is certainly an overloaded primitive type!).

Constructors

Subst [TypeParam] t |
ExpSubst Exp |

#### Instances

Instances details

Functor Subst Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods fmap :: (a -> b) -> Subst a -> Subst b Source # (<$) :: a -> Subst b -> Subst a Source #
Show t => Show (Subst t) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods showsPrec :: Int -> Subst t -> ShowS Source # show :: Subst t -> String Source # showList :: [Subst t] -> ShowS Source #
Pretty t => Pretty (Subst t) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods pretty :: Subst t -> Doc ann Source # prettyList :: [Subst t] -> Doc ann Source #

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 #

#### Instances

Instances details

Substitutable Exp Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> Exp -> Exp Source #
Substitutable ParamType Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> ParamType -> ParamType Source #
Substitutable StructType Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> StructType -> StructType Source #
Substitutable (Pat ParamType) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> Pat ParamType -> Pat ParamType Source #
Substitutable (Pat StructType) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> Pat StructType -> Pat StructType Source #
Substitutable d => Substitutable (Shape d) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> Shape d -> Shape d Source #
Substitutable (RetTypeBase Size NoUniqueness) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> RetTypeBase Size NoUniqueness -> RetTypeBase Size NoUniqueness Source #
Substitutable (RetTypeBase Size Uniqueness) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> RetTypeBase Size Uniqueness -> RetTypeBase Size Uniqueness Source #
Substitutable (TypeBase Size Uniqueness) Source # |
Instance details Defined in Language.Futhark.TypeChecker.Types Methods applySubst :: TypeSubs -> TypeBase Size Uniqueness -> TypeBase Size Uniqueness Source #

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.