CallValue allows us to easily incorporate builtin functions along side Javascript functions.

data CallValue = CallJS [SourceElement] | CallBuiltIn (InterpM Value)

The class

class SubType sub sup where
inj :: sub -> sup
prj :: sup -> Maybe sub

allows us to inject into a Value type, and project out of it.

3.2 Monads

-- Context is a scope chain, variable object, this and current function
type Ctx = ([ObjId], ObjId, ObjId, ObjId)
-- State is a context stack, object store and line and column of current statement being used.
type JSState = ([Ctx], Map ObjId Object,(Int,Int))
-- Compose state and error. The order is important, if it where the other way round state would be lost.
type InterpM = ErrorT Throwable (StateT JSState Identity)

3.3 Parser/Lexer

The lexer and parser are two seperate instances of a Parsec parser. The tokens which are returned by the Lexer are:

Properties on an object have a list of attributes which indicate if the property is to be included in enumeration, is writable etc. There are functions to get and set property values. The 'getProperty' function will traverse up the __proto__ chain looking for the property.