ddc-core-0.4.3.1: Disciplined Disciple Compiler core language and type checker.

Safe HaskellSafe
LanguageHaskell98

DDC.Core.Env.EnvT

Contents

Description

Environment of a type expression.

An environment contains the types named bound variables, named primitives, and a deBruijn stack for anonymous variables.

Synopsis

Documentation

data EnvT n Source #

A type environment.

Constructors

EnvT 

Fields

Construction

empty :: EnvT n Source #

An empty environment.

singleton :: Ord n => Bind n -> EnvT n Source #

Construct a singleton type environment.

extend :: Ord n => Bind n -> EnvT n -> EnvT n Source #

Extend an environment with a new binding. Replaces bindings with the same name already in the environment.

extends :: Ord n => [Bind n] -> EnvT n -> EnvT n Source #

Extend an environment with a list of new bindings. Replaces bindings with the same name already in the environment.

union :: Ord n => EnvT n -> EnvT n -> EnvT n Source #

Combine two environments. If both environments have a binding with the same name, then the one in the second environment takes preference.

unions :: Ord n => [EnvT n] -> EnvT n Source #

Combine multiple environments, with the latter ones taking preference.

Conversion

fromList :: Ord n => [Bind n] -> EnvT n Source #

Convert a list of Binds to an environment.

fromListNT :: Ord n => [(n, Type n)] -> EnvT n Source #

Convert a list of name and types into an environment

fromTypeMap :: Map n (Type n) -> EnvT n Source #

Convert a map of names to types to a environment.

kindEnvOfEnvT :: Ord n => EnvT n -> KindEnv n Source #

Extract a KindEnv from an EnvT.

Projections

depth :: EnvT n -> Int Source #

Yield the total depth of the deBruijn stack.

member :: Ord n => Bound n -> EnvT n -> Bool Source #

Check whether a bound variable is present in an environment.

memberBind :: Ord n => Bind n -> EnvT n -> Bool Source #

Check whether a binder is already present in the an environment. This can only return True for named binders, not anonymous or primitive ones.

lookup :: Ord n => Bound n -> EnvT n -> Maybe (Type n) Source #

Lookup a bound variable from an environment.

lookupName :: Ord n => n -> EnvT n -> Maybe (Type n) Source #

Lookup a bound name from an environment.

Primitives

setPrimFun :: (n -> Maybe (Type n)) -> EnvT n -> EnvT n Source #

Set the function that knows the types of primitive things.

isPrim :: EnvT n -> n -> Bool Source #

Check if the type of a name is defined by the envPrimFun.

Lifting

lift :: Ord n => Int -> EnvT n -> EnvT n Source #

Lift all free deBruijn indices in the environment by the given number of steps.