This module manages the context that an expression runs with. Specifically it is used to assign values to constants, and set functions that can be called from the expression.
context : Context
context =
Context.empty
|> Context.addConstant "x" 5
|> Context.addFunction "stringToInt" stringToInt
Eexl.evaluateInt context """x + 5 + stringToInt("7")""" -- = Ok 17
This is the type of Context
that is passed into the functions that evaluate expressions.
empty : Context
An empty context containing no functions or constants.
addConstant : String -> Basics.Int -> Context -> Context
Add a constant to the context.
addFunction : String -> (String -> Basics.Int) -> Context -> Context
Add a function to the context.
getConstant : String -> Context -> Maybe Basics.Int
Retrieve a constant from the context (not usually used).
getFunction : String -> Context -> Maybe (String -> Basics.Int)
Retrieve a constant from the context (not usually used).