Safe Haskell | Safe-Infered |
---|

Type environments.

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

- data Env n = Env {
- envMap :: Map n (Type n)
- envStack :: [Type n]
- envStackLength :: Int
- envPrimFun :: n -> Maybe (Type n)

- empty :: Env n
- extend :: Ord n => Bind n -> Env n -> Env n
- extends :: Ord n => [Bind n] -> Env n -> Env n
- setPrimFun :: (n -> Maybe (Type n)) -> Env n -> Env n
- isPrim :: Env n -> n -> Bool
- fromList :: Ord n => [Bind n] -> Env n
- union :: Ord n => Env n -> Env n -> Env n
- member :: Ord n => Bound n -> Env n -> Bool
- memberBind :: Ord n => Bind n -> Env n -> Bool
- lookup :: Ord n => Bound n -> Env n -> Maybe (Type n)
- lookupName :: Ord n => n -> Env n -> Maybe (Type n)
- depth :: Env n -> Int
- wrapTForalls :: Ord n => Env n -> Type n -> Type n

# Documentation

A type environment.

extend :: Ord n => Bind n -> Env n -> Env nSource

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

extends :: Ord n => [Bind n] -> Env n -> Env nSource

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

setPrimFun :: (n -> Maybe (Type n)) -> Env n -> Env nSource

Set the function that knows the types of primitive things.

isPrim :: Env n -> n -> BoolSource

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

.

union :: Ord n => Env n -> Env n -> Env nSource

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

member :: Ord n => Bound n -> Env n -> BoolSource

Check whether a bound variable is present in an environment.

memberBind :: Ord n => Bind n -> Env n -> BoolSource

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