Application (spec/02 §7): a design's variables resolved and its facts read, so what is left is a design with no hole in it.
Variables are parameters given at the use site (§7.2). bindings/2 judges what a
site gives: a literal is checked against the declaration by
Macaw.Data.Parameter.validate/2; {:state, source} binds the variable to a state
source, which needs a default (:bindable_without_default) and a type (a :term
variable is {:not_bindable, "vars.<name>"}). apply/2 substitutes the values,
defaults filling what is not given: resolution is single level, so a value that is
itself a variable is {:var_binding, name} at every path the variable stood, and a
variable with no value and no default is {:unresolved, :var, name} there. A bound
variable is read at its default. Facts are then read from the schemas
(Macaw.Frame.Document.Facts), and the result is judged whole, so a value is typed at
the path where its variable stood.
iex> design = %{vars: %{"unit" => %{type: :text, default: "ms"}},
...> frames: %{"main" => %{kind: "cartesian"}},
...> labels: [%{anchor: :title, text: "in \#{var(unit)}"}]}
iex> {:ok, applied} = Macaw.Frame.Document.Apply.apply(design, vars: %{"unit" => "s"})
iex> applied.labels
[%{anchor: :title, text: "in s"}]
Summary
Functions
A design applied (§7): vars: the values a site or a host gives (%{name => value},
{:state, source} read at the variable's default), schemas: the schema bound to each
slot (%{slot => Macaw.Data.Schema.t()}) its facts are read from, opts of
Macaw.Frame.Document.check/2 beside them. {:ok, design} with no variable or fact
left, or every fault.
The site's bindings of a design's variables judged (§2.4, §7.2): {:ok, values}, each
variable's value (a state-bound one at its default), or every fault at the binding's
name.
A design's variables resolved (§7.2, step 2 of compilation, §12.1): {:ok, design, values, bound}, the design with every variable replaced (its vars declarations
kept), each variable's value, and each variable given binds to state with the paths it
stood at (%{name => [path]}), which Macaw.Frame.Compiled.bound/3 re-resolves; or
every fault, {:unresolved, :var, name} and {:var_binding, name} at each path.
Functions
@spec apply(term(), term()) :: {:ok, map()} | {:error, [Macaw.Base.Fault.t(), ...]}
A design applied (§7): vars: the values a site or a host gives (%{name => value},
{:state, source} read at the variable's default), schemas: the schema bound to each
slot (%{slot => Macaw.Data.Schema.t()}) its facts are read from, opts of
Macaw.Frame.Document.check/2 beside them. {:ok, design} with no variable or fact
left, or every fault.
@spec bindings(term(), term()) :: {:ok, map()} | {:error, [Macaw.Base.Fault.t(), ...]}
The site's bindings of a design's variables judged (§2.4, §7.2): {:ok, values}, each
variable's value (a state-bound one at its default), or every fault at the binding's
name.
@spec variables(term(), term()) :: {:ok, map(), map(), %{required(String.t()) => [list()]}} | {:error, [Macaw.Base.Fault.t(), ...]}
A design's variables resolved (§7.2, step 2 of compilation, §12.1): {:ok, design, values, bound}, the design with every variable replaced (its vars declarations
kept), each variable's value, and each variable given binds to state with the paths it
stood at (%{name => [path]}), which Macaw.Frame.Compiled.bound/3 re-resolves; or
every fault, {:unresolved, :var, name} and {:var_binding, name} at each path.