View Source Formulae.Compiler (formulae v0.15.2)

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

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

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

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

View Source
@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.

Link to this function

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

View Source
@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.

Link to this function

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

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

Returns all the compiled Formulae modules known to the system.