View Source Protean.Machine (Protean v0.0.1)

Purely-functional statechart core.

Provides the underlying state-transition logic for a statechart, primarily through transition/3, a higher-level transition API for using %Protean.Machine{} apart from the interpreter provided by Protean, and take_transitions/3, a lower-level API used by a statechart interpreter.

It is uncommon to use this module independently of the Protean behaviour.

Link to this section Summary

Types

t()

A full Protean machine configuration.

Functions

Returns the initial Protean.State for a given machine.

Given a machine, a machine state, and an event, transition to the next state if the machine defines a transition for the given state and event.

Link to this section Types

@type t() :: %Protean.Machine{
  handler: module(),
  idmap: %{required(Protean.Node.id()) => Protean.Node.t()},
  initial_context: Protean.State.context(),
  root: Protean.Node.t()
}

A full Protean machine configuration.

Link to this section Functions

@spec initial_state(t()) :: Protean.State.t()

Returns the initial Protean.State for a given machine.

Link to this function

select_automatic_transitions(machine, state)

View Source
@spec select_automatic_transitions(t(), Protean.State.t()) :: [Protean.Transition.t()]
Link to this function

select_transitions(machine, state, event)

View Source
@spec select_transitions(t(), Protean.State.t(), Protean.event()) :: [
  Protean.Transition.t()
]
Link to this function

take_transitions(machine, state, transitions)

View Source
@spec take_transitions(t(), Protean.State.t(), [Protean.Transition.t()]) ::
  Protean.State.t()
Link to this function

transition(machine, state, event)

View Source
@spec transition(t(), Protean.State.t(), Protean.event()) :: Protean.State.t()

Given a machine, a machine state, and an event, transition to the next state if the machine defines a transition for the given state and event.