finos/morphir-elm/13.0.0

NOTE: the latest version is 22.0.2

Formerly Morgan-Stanley/morphir-elm. Search finds this package by either name.

Morphir.Value.Interpreter

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 FQName Function -> IR -> RawValue -> Result Error 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))
Dict FQName Function
-> IR
-> Variables
-> List RawValue
-> RawValue
-> Result Error RawValue

Evaluates a value expression recursively in a single pass while keeping track of variables and arguments along the evaluation.

Dict FQName Function
-> IR
-> FQName
-> List RawValue
-> Result Error RawValue
matchPattern : Pattern () -> RawValue -> Result 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.