stgi-1.1: Educational implementation of the STG (Spineless Tagless G-machine)

Safe HaskellNone
LanguageHaskell2010

Stg.Machine.Env

Contents

Description

Defines operations on local and global variable environments.

Synopsis

Locals

addLocals :: [Mapping Var Value] -> Locals -> Locals Source #

Add a list of bindings to the local environment.

Already existing variables will be shadowed (i.e. overwritten).

makeLocals :: [Mapping Var Value] -> Locals Source #

Create a local environment from a list of bindings.

val :: Locals -> Globals -> Atom -> Validate NotInScope Value Source #

Look up the value of an Atom first in the local, then in the global environment.

vals :: Locals -> Globals -> [Atom] -> Validate NotInScope [Value] Source #

Look up the values of many Atoms, and return their values in the input's order, or a list of variables not in scope.

localVal :: Locals -> Atom -> Validate NotInScope Value Source #

Look up the value of a variable in the local environment.

newtype NotInScope Source #

Type safety wrapper to report variables that were not in scope.

Constructors

NotInScope [Var] 

Instances

Eq NotInScope Source # 
Ord NotInScope Source # 
Show NotInScope Source # 
Generic NotInScope Source # 

Associated Types

type Rep NotInScope :: * -> * #

Semigroup NotInScope Source # 
Monoid NotInScope Source # 
NFData NotInScope Source # 

Methods

rnf :: NotInScope -> () #

PrettyStgi NotInScope Source # 
type Rep NotInScope Source # 
type Rep NotInScope = D1 (MetaData "NotInScope" "Stg.Machine.Types" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" True) (C1 (MetaCons "NotInScope" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Var])))

Globals

globalVal :: Globals -> Atom -> Validate NotInScope Value Source #

Look up the value of a variable in the global environment.