# `Statifier.Evaluator.Functions`
[🔗](https://github.com/riddler/statifier-ex/blob/v2.0.0/lib/statifier/evaluator/functions.ex#L1)

The `Predicator.FunctionProvider` carrying `In/1` (spec 5.9.1), replacing
`Statifier.Evaluator`'s former private closure-building helper.

A provider entry is named by `{module, atom}` rather than by a captured
`function()` value (`deps/predicator/lib/predicator/functions/provider.ex`),
so `in_state/2` reads the current configuration from its
`%Predicator.Context{}` argument's `host` slot instead of closing over it.
`Statifier.Evaluator.context/1` sets `host` to `{machine, configuration}`
and refreshes it per site with `Predicator.Context.put_host/2` - see that
module's moduledoc for why this dissolves the "not a resumable position"
ground the closure used to force.

# `base_context`

```elixir
@spec base_context() :: Predicator.Context.t()
```

The fixed half of every context this library builds: an empty `data`, a
`nil` `host`, `on_unbound: :error`, and `functions` resolved once at
compile time to `%{"In" => {1, {Statifier.Evaluator.Functions, :in_state}}}` plus
the four builtin providers. `Statifier.Evaluator.context/1` starts from
this constant on every call, then layers in `host` via
`Predicator.Context.put_host/2` and the datamodel via
`Statifier.Evaluator.bind/3` - so `Predicator.Context.new/2` and
`Predicator.Context.resolve_functions/1` never run on that hot path.

Two calls return the same term; nothing about this value varies at
runtime.

# `functions`

```elixir
@spec functions() :: %{required(String.t()) =&gt; {non_neg_integer(), atom()}}
```

This provider's one entry: `In/1`, dispatched to `in_state/2`.

# `in_state`

```elixir
@spec in_state(args :: [Predicator.Types.value()], context :: Predicator.Context.t()) ::
  {:ok, boolean()}
```

`In(stateId)`: true when `stateId` names a state in `context.host`'s
configuration, false for an inactive or undeclared state id.

`context.host` must be `{machine, configuration}`, the shape
`Statifier.Evaluator.context/1` sets via `Predicator.Context.put_host/2`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
