futhark
Safe HaskellNone
LanguageGHC2021

Language.Futhark.TypeChecker.Terms.Scope

Description

The notion of scope used during term checking, and other small definitions shared between the unsized term checker (Language.Futhark.TypeChecker.Terms.Unsized) and the sized one (Language.Futhark.TypeChecker.Terms). The two checkers represent sizes differently, so the definitions here are parameterised over the size representation, and the functions take a function for converting the sizes of module-level types.

Synopsis

Documentation

data ValBinding dim Source #

What a bound value stands for. Note that although modules are in the same name space, they are not value bindings.

Constructors

BoundV [TypeParam] (TypeBase dim NoMode) 
OverloadedF [PrimType] [Maybe PrimType] (Maybe PrimType) 
EqualityF 
RecursiveV

A recursive function with no declared return type, currently being checked and in scope of its own body. Each occurrence adopts the type recorded for it by the unsized type checker, with fresh (unrelated) sizes. See Note [Checking recursive functions] in Language.Futhark.TypeChecker.Terms.

Instances

Instances details
Show dim => Show (ValBinding dim) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Scope

Methods

showsPrec :: Int -> ValBinding dim -> ShowS #

show :: ValBinding dim -> String #

showList :: [ValBinding dim] -> ShowS #

data TermScope dim Source #

The lexical scope information.

Instances

Instances details
Semigroup (TermScope dim) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Scope

Methods

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

sconcat :: NonEmpty (TermScope dim) -> TermScope dim #

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

Show dim => Show (TermScope dim) Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Scope

Methods

showsPrec :: Int -> TermScope dim -> ShowS #

show :: TermScope dim -> String #

showList :: [TermScope dim] -> ShowS #

data Inferred t Source #

During type checking a pattern, we might find an explicit ascription. These contain complete type information (although they must of course still be checked against what remains of the pattern).

Constructors

NoneInferred 
Ascribed t 

Instances

Instances details
Functor Inferred Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Terms.Scope

Methods

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

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

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

Defined in Language.Futhark.TypeChecker.Terms.Scope

Methods

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

show :: Inferred t -> String #

showList :: [Inferred t] -> ShowS #

envToTermScope :: (StructType -> TypeBase dim NoMode) -> Env -> TermScope dim Source #

Create a scope from a module-level environment.

envToTermScopeNoVals :: Env -> TermScope dim Source #

Like envToTermScope, but omits the (potentially very large) value table. Its bindings are instead looked up on demand with lookupOuterVal. This avoids transforming the entire value table of the outer environment - which for a top-level definition includes the whole prelude - once for every binding we check.

lookupOuterVal :: (StructType -> TypeBase dim NoMode) -> Env -> VName -> Maybe (ValBinding dim) Source #

Look up a single value binding in an Env and convert it, using the given size conversion. The fallback for names not found in the (value-free) term scope built by envToTermScopeNoVals.

initialTermScope :: (StructType -> TypeBase dim NoMode) -> TermScope dim Source #

The initial scope, containing the intrinsics.

lookupQualNameEnv :: (StructType -> TypeBase dim NoMode) -> TermScope dim -> QualName VName -> TermScope dim Source #

Find the scope corresponding to the qualifiers of the given name. Fails with error if the qualifiers do not name a module, as this means the program should not have made it through earlier checks.

lookupQualNameEnvMaybe :: (StructType -> TypeBase dim NoMode) -> TermScope dim -> QualName VName -> Maybe (TermScope dim) Source #

As lookupQualNameEnv, but Nothing when the qualifiers do not name a module in this scope. Use this when the name is merely being looked up opportunistically, and so may well be one that has gone out of scope.

typeParamIdent :: TypeParam -> Maybe (Ident StructType) Source #

An identifier corresponding to a type parameter, for size parameters, which also exist as terms.