View Source Formulae.Compiler (formulae v0.17.1)

The process to be spawned to compile Formulae instances without clashes.

Elixir is great in parallel compilation, and in highly concurrent environment in-place compilation of the same formulas might result in clashes.

If your application already uses Finitomata, compiler would be created as an instance of it, simply launch it as

Finitomata.start_fsm YOUR_FINITOMATA_SUP, Formulae.Compiler, "Compiler", nil

otherwise it’ll be compiled into a regular GenServer module exporting start_link/0.

Once started, one might simply use Compiler.compile(formula, options) and Compiler.eval(formula, options).

Summary

Functions

Returns a specification to start this module under a supervisor.

Compiles a formula if it has not yet been compiled, otherwise it’s a noop.

Evaluates a formula. If it hsa not been compiled yet, sinchronously compiles it first.

Returns all the compiled Formulae modules known to the system.

Types

t()

@type t() :: %Formulae.Compiler{
  payload: term(),
  formulas: %{optional(binary()) => Formulae.t()}
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

compile(id \\ nil, name \\ __MODULE__, formula, options)

@spec compile(id :: term(), name :: term(), formula :: binary(), options :: keyword()) ::
  :ok

Compiles a formula if it has not yet been compiled, otherwise it’s a noop.

eval(id \\ nil, name \\ __MODULE__, formula, binding)

@spec eval(
  id :: Finitomata.id(),
  name :: Finitomata.fsm_name(),
  formula :: Formulae.t() | binary() | {binary(), keyword()},
  binding :: keyword()
) :: any()

Evaluates a formula. If it hsa not been compiled yet, sinchronously compiles it first.

formulas(id \\ nil, name \\ __MODULE__)

@spec formulas(id :: term(), name :: term()) :: %{optional(binary()) => Formulae.t()}

Returns all the compiled Formulae modules known to the system.

start_link(opts \\ [])