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

Language.Futhark.TypeChecker.Terms.Monad

Description

Facilities for type-checking terms. Factored out of Language.Futhark.TypeChecker.Terms to prevent the module from being gigantic.

Incidentally also a nice place to put Haddock comments to make the internal API of the type checker easier to browse.

Synopsis

Documentation

data TermTypeM a Source #

Instances

Instances details
MonadTypeChecker TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

MonadUnify TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Applicative TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

pure :: a -> TermTypeM a

(<*>) :: TermTypeM (a -> b) -> TermTypeM a -> TermTypeM b

liftA2 :: (a -> b -> c) -> TermTypeM a -> TermTypeM b -> TermTypeM c

(*>) :: TermTypeM a -> TermTypeM b -> TermTypeM b

(<*) :: TermTypeM a -> TermTypeM b -> TermTypeM a

Functor TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

fmap :: (a -> b) -> TermTypeM a -> TermTypeM b

(<$) :: a -> TermTypeM b -> TermTypeM a

Monad TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

(>>=) :: TermTypeM a -> (a -> TermTypeM b) -> TermTypeM b

(>>) :: TermTypeM a -> TermTypeM b -> TermTypeM b

return :: a -> TermTypeM a

MonadError TypeError TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

MonadReader TermEnv TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

ask :: TermTypeM TermEnv #

local :: (TermEnv -> TermEnv) -> TermTypeM a -> TermTypeM a #

reader :: (TermEnv -> a) -> TermTypeM a #

MonadState TermTypeState TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

runTermTypeM :: (ExpBase (NoInfo :: Type -> Type) VName -> TermTypeM Exp) -> TermTypeM a -> TypeM a Source #

data ValBinding Source #

Instances

Instances details
Show ValBinding Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

showsPrec :: Int -> ValBinding -> ShowS

show :: ValBinding -> String

showList :: [ValBinding] -> ShowS

data SizeSource Source #

What was the source of some existential size? This is used for using the same existential variable if the same source is encountered in multiple locations.

Constructors

SourceSlice (Maybe Size) (Maybe (ExpBase (NoInfo :: Type -> Type) VName)) (Maybe (ExpBase (NoInfo :: Type -> Type) VName)) (Maybe (ExpBase (NoInfo :: Type -> Type) VName)) 

Instances

Instances details
Show SizeSource Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

showsPrec :: Int -> SizeSource -> ShowS

show :: SizeSource -> String

showList :: [SizeSource] -> ShowS

Eq SizeSource Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

(==) :: SizeSource -> SizeSource -> Bool

(/=) :: SizeSource -> SizeSource -> Bool

Ord SizeSource Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

data Inferred t Source #

Constructors

NoneInferred 
Ascribed t 

Instances

Instances details
Functor Inferred Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

fmap :: (a -> b) -> Inferred a -> Inferred b

(<$) :: a -> Inferred b -> Inferred a

data TermEnv Source #

Type checking happens with access to this environment. The TermScope will be extended during type-checking as bindings come into scope.

Instances

Instances details
MonadReader TermEnv TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

ask :: TermTypeM TermEnv #

local :: (TermEnv -> TermEnv) -> TermTypeM a -> TermTypeM a #

reader :: (TermEnv -> a) -> TermTypeM a #

data TermScope Source #

Instances

Instances details
Semigroup TermScope Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

(<>) :: TermScope -> TermScope -> TermScope #

sconcat :: NonEmpty TermScope -> TermScope

stimes :: Integral b => b -> TermScope -> TermScope

Show TermScope Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

Methods

showsPrec :: Int -> TermScope -> ShowS

show :: TermScope -> String

showList :: [TermScope] -> ShowS

data TermTypeState Source #

The state is a set of constraints and a counter for generating type names. This is distinct from the usual counter we use for generating unique names, as these will be user-visible.

Instances

Instances details
MonadState TermTypeState TermTypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Monad

expType :: Exp -> TermTypeM StructType Source #

Get the type of an expression, with top level type variables substituted. Never call typeOf directly (except in a few carefully inspected locations)!

expTypeFully :: Exp -> TermTypeM StructType Source #

Get the type of an expression, with all type variables substituted. Slower than expType, but sometimes necessary. Never call typeOf directly (except in a few carefully inspected locations)!

allDimsFreshInType :: Usage -> Rigidity -> Name -> TypeBase Size als -> TermTypeM (TypeBase Size als, Map VName Size) Source #

Replace *all* dimensions with distinct fresh size variables.

updateTypes :: ASTMappable e => e -> TermTypeM e Source #

Replace all type variables with their concrete types.

type Names = Set VName Source #

Primitive checking

require :: Text -> [PrimType] -> Exp -> TermTypeM Exp Source #

require ts e causes a TypeError if expType e is not one of the types in ts. Otherwise, simply returns e.

Sizes

isInt64 :: Exp -> Maybe Int64 Source #

Control flow

Errors