This module contains an interpreter for Morphir expressions. The interpreter takes a piece of logic as input,
evaluates it and returns the resulting data. In Morphir both logic and data is captured as a Value
so the interpreter
takes a Value
and returns a Value
(or an error for invalid expressions):
evaluate : Dict Morphir.IR.FQName.FQName Morphir.Value.Native.Function -> Morphir.IR.Distribution.Distribution -> Morphir.IR.Value.RawValue -> Result Morphir.Value.Error.Error Morphir.IR.Value.RawValue
Evaluates a value expression and returns another value expression or an error. You can also pass in other values by fully-qualified name that will be used for lookup if the expression contains references.
evaluate
SDK.nativeFunctions
(Value.Apply ()
(Value.Reference () (fqn "Morphir.SDK" "Basics" "not"))
(Value.Literal () (BoolLiteral True))
)
-- (Value.Literal () (BoolLiteral False))
evaluateValue : Dict Morphir.IR.FQName.FQName Morphir.Value.Native.Function -> Morphir.IR.Distribution.Distribution -> Variables -> List Morphir.IR.Value.RawValue -> Morphir.IR.Value.RawValue -> Result Morphir.Value.Error.Error Morphir.IR.Value.RawValue
Evaluates a value expression recursively in a single pass while keeping track of variables and arguments along the evaluation.
evaluateFunctionValue : Dict Morphir.IR.FQName.FQName Morphir.Value.Native.Function -> Morphir.IR.Distribution.Distribution -> Morphir.IR.FQName.FQName -> List (Maybe Morphir.IR.Value.RawValue) -> Result Morphir.Value.Error.Error Morphir.IR.Value.RawValue
matchPattern : Morphir.IR.Value.Pattern () -> Morphir.IR.Value.RawValue -> Result Morphir.Value.Error.PatternMismatch Variables
Matches a value against a pattern recursively. It either returns an error if there is a mismatch or a dictionary of variable names to values extracted out of the pattern.
Dict Morphir.IR.Name.Name Morphir.IR.Value.RawValue
Dictionary of variable name to value.