| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data ValBinding dim
- data TermScope dim = TermScope {
- scopeVtable :: Map VName (ValBinding dim)
- scopeTypeTable :: Map VName TypeBinding
- scopeModTable :: Map VName Mod
- data Inferred t
- = NoneInferred
- | Ascribed t
- envToTermScope :: (StructType -> TypeBase dim NoMode) -> Env -> TermScope dim
- envToTermScopeNoVals :: Env -> TermScope dim
- lookupOuterVal :: (StructType -> TypeBase dim NoMode) -> Env -> VName -> Maybe (ValBinding dim)
- initialTermScope :: (StructType -> TypeBase dim NoMode) -> TermScope dim
- lookupQualNameEnv :: (StructType -> TypeBase dim NoMode) -> TermScope dim -> QualName VName -> TermScope dim
- lookupQualNameEnvMaybe :: (StructType -> TypeBase dim NoMode) -> TermScope dim -> QualName VName -> Maybe (TermScope dim)
- typeParamIdent :: TypeParam -> Maybe (Ident StructType)
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
| Show dim => Show (ValBinding dim) Source # | |
Defined in Language.Futhark.TypeChecker.Terms.Scope Methods showsPrec :: Int -> ValBinding dim -> ShowS # show :: ValBinding dim -> String # showList :: [ValBinding dim] -> ShowS # | |
The lexical scope information.
Constructors
| TermScope | |
Fields
| |
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 |
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.