Elex.Variable (Elex v0.4.0)
View SourceA named value with a type used during expression validation and evaluation.
Variables are stored on a Elex.Context and referenced in expressions
by name. The :type field drives type checking in Elex.Validator;
the :value field is returned by Elex.Evaluator.
Fields
:type- One of:decimal,:boolean,:string,:percent,nil,:unknown, or a unit category atom such as:length:value- The runtime value (Decimal.t(),boolean(),String.t(),Elex.Percent.t(),{number, unit}orElex.Quantity.t()for a categorized quantity, etc.)
Examples
%Elex.Variable{value: Decimal.new("3.14"), type: :decimal}
%Elex.Variable{value: true, type: :boolean}
%Elex.Variable{value: "hello", type: :string}
%Elex.Variable{value: %Elex.Percent{value: Decimal.new("50")}, type: :percent}Use Elex.add_variable/3 to infer the type from a value.