futhark-0.18.3: An optimising compiler for a functional, array-oriented language.
Safe HaskellTrustworthy
LanguageHaskell2010

Language.Futhark.TypeChecker.Monad

Description

Main monad in which the type checker runs, as well as ancillary data definitions.

Synopsis

Documentation

data TypeM a Source #

The type checker runs in this monad.

Instances

Instances details
Monad TypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

(>>=) :: TypeM a -> (a -> TypeM b) -> TypeM b #

(>>) :: TypeM a -> TypeM b -> TypeM b #

return :: a -> TypeM a #

Functor TypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

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

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

Applicative TypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

pure :: a -> TypeM a #

(<*>) :: TypeM (a -> b) -> TypeM a -> TypeM b #

liftA2 :: (a -> b -> c) -> TypeM a -> TypeM b -> TypeM c #

(*>) :: TypeM a -> TypeM b -> TypeM b #

(<*) :: TypeM a -> TypeM b -> TypeM a #

MonadTypeChecker TypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

MonadError TypeError TypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

throwError :: TypeError -> TypeM a #

catchError :: TypeM a -> (TypeError -> TypeM a) -> TypeM a #

askEnv :: TypeM Env Source #

Retrieve the current Env.

askImportName :: TypeM ImportName Source #

The name of the current file/import.

bindSpaced :: MonadTypeChecker m => [(Namespace, Name)] -> m a -> m a Source #

Map source-level names do fresh unique internal names, and evaluate a type checker context with the mapping active.

qualifyTypeVars :: Env -> [VName] -> [VName] -> TypeBase (DimDecl VName) as -> TypeBase (DimDecl VName) as Source #

Try to prepend qualifiers to the type names such that they represent how to access the type in some scope.

lookupMTy :: SrcLoc -> QualName Name -> TypeM (QualName VName, MTy) Source #

Look up a module type.

lookupImport :: SrcLoc -> FilePath -> TypeM (FilePath, Env) Source #

Look up an import.

localEnv :: Env -> TypeM a -> TypeM a Source #

Evaluate a TypeM computation within an extended (not replaced) environment.

data TypeError Source #

Information about an error during type checking.

Constructors

TypeError SrcLoc Notes Doc 

Instances

Instances details
Pretty TypeError Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

ppr :: TypeError -> Doc #

pprPrec :: Int -> TypeError -> Doc #

pprList :: [TypeError] -> Doc #

MonadError TypeError TypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

throwError :: TypeError -> TypeM a #

catchError :: TypeM a -> (TypeError -> TypeM a) -> TypeM a #

unappliedFunctor :: MonadTypeChecker m => SrcLoc -> m a Source #

An unexpected functor appeared!

unknownVariable :: MonadTypeChecker m => Namespace -> QualName Name -> SrcLoc -> m a Source #

An unknown variable was referenced.

unknownType :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a Source #

An unknown type was referenced.

underscoreUse :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a Source #

A name prefixed with an underscore was used.

data Notes Source #

A collection of Notes.

Instances

Instances details
Semigroup Notes Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

(<>) :: Notes -> Notes -> Notes #

sconcat :: NonEmpty Notes -> Notes #

stimes :: Integral b => b -> Notes -> Notes #

Monoid Notes Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

mempty :: Notes #

mappend :: Notes -> Notes -> Notes #

mconcat :: [Notes] -> Notes #

Pretty Notes Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

Methods

ppr :: Notes -> Doc #

pprPrec :: Int -> Notes -> Doc #

pprList :: [Notes] -> Doc #

aNote :: Pretty a => a -> Notes Source #

A single note.

class Monad m => MonadTypeChecker m where Source #

Monads that support type checking. The reason we have this internal interface is because we use distinct monads for checking expressions and declarations.

checkName :: MonadTypeChecker m => Namespace -> Name -> SrcLoc -> m VName Source #

Elaborate the given name in the given namespace at the given location, producing the corresponding unique VName.

badOnLeft :: Either TypeError a -> TypeM a Source #

Turn a Left TypeError into an actual error.

data Env Source #

Modules produces environment with this representation.

Instances

Instances details
Show Env Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

showsPrec :: Int -> Env -> ShowS #

show :: Env -> String #

showList :: [Env] -> ShowS #

Semigroup Env Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

(<>) :: Env -> Env -> Env #

sconcat :: NonEmpty Env -> Env #

stimes :: Integral b => b -> Env -> Env #

Monoid Env Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

mempty :: Env #

mappend :: Env -> Env -> Env #

mconcat :: [Env] -> Env #

Pretty Env Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

ppr :: Env -> Doc #

pprPrec :: Int -> Env -> Doc #

pprList :: [Env] -> Doc #

type TySet = Map (QualName VName) Liftedness Source #

A mapping of abstract types to their liftedness.

data FunSig Source #

A parametric functor consists of a set of abstract types, the environment of its parameter, and the resulting module type.

Constructors

FunSig 

Instances

Instances details
Show FunSig Source # 
Instance details

Defined in Language.Futhark.Semantic

type ImportTable = Map String Env Source #

A mapping from import strings to Envs. This is used to resolve import declarations.

type NameMap = Map (Namespace, Name) (QualName VName) Source #

A mapping from names (which always exist in some namespace) to a unique (tagged) name.

data BoundV Source #

Type parameters, list of parameter types (optinally named), and return type. The type parameters are in scope in both parameter types and the return type. Non-functional values have only a return type.

Constructors

BoundV [TypeParam] StructType 

Instances

Instances details
Show BoundV Source # 
Instance details

Defined in Language.Futhark.Semantic

data Mod Source #

Representation of a module, which is either a plain environment, or a parametric module ("functor" in SML).

Constructors

ModEnv Env 
ModFun FunSig 

Instances

Instances details
Show Mod Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

showsPrec :: Int -> Mod -> ShowS #

show :: Mod -> String #

showList :: [Mod] -> ShowS #

Pretty Mod Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

ppr :: Mod -> Doc #

pprPrec :: Int -> Mod -> Doc #

pprList :: [Mod] -> Doc #

data TypeBinding Source #

A binding from a name to its definition as a type.

Instances

Instances details
Eq TypeBinding Source # 
Instance details

Defined in Language.Futhark.Semantic

Show TypeBinding Source # 
Instance details

Defined in Language.Futhark.Semantic

data MTy Source #

Representation of a module type.

Constructors

MTy 

Fields

Instances

Instances details
Show MTy Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

showsPrec :: Int -> MTy -> ShowS #

show :: MTy -> String #

showList :: [MTy] -> ShowS #

Pretty MTy Source # 
Instance details

Defined in Language.Futhark.Semantic

Methods

ppr :: MTy -> Doc #

pprPrec :: Int -> MTy -> Doc #

pprList :: [MTy] -> Doc #

anySignedType :: [PrimType] Source #

All signed integer types.

anyUnsignedType :: [PrimType] Source #

All unsigned integer types.

anyFloatType :: [PrimType] Source #

All floating-point types.

anyNumberType :: [PrimType] Source #

All number types.

anyPrimType :: [PrimType] Source #

All primitive types.

intrinsicsNameMap :: NameMap Source #

The NameMap corresponding to the intrinsics module.

topLevelNameMap :: NameMap Source #

The names that are available in the initial environment.