Lab42.StateMachine v0.1.0 Lab42.StateMachine.Runner View Source

Runs the state machine by finding and executing transitions

Link to this section Summary

Functions

Convenience transformer function to stop the state machine, can be used with the atom :halt

Convenience function to push an input to the output without changing it, can be used with the atom :id in the transformer position of a transition, e.g. {~r{alpha}, :id, fn count, _ -> count + 1 end}

Convenience function to not change the data. It can be used with the atom :id in the updater position of a transition, e.g. {~r{alpha}, fn {_, line} -> String.reverse(line), :id}

Convenience function to ignore an input, it can be used with the atom :ignore in the transformer position of a transition, e.g. {~r{alpha}, :ignore, fn count, _ -> count + 1 end}

Link to this section Types

Link to this type

empty_t()

View Source
empty_t() :: []
Link to this type

error_t()

View Source
error_t() :: {:error, list() | String.t(), state_t()}
Link to this type

match_t()

View Source
match_t() :: {any(), any()}
Link to this type

maybe(a_type)

View Source
maybe(a_type) :: a_type | nil
Link to this type

normalized_transitions_t()

View Source
normalized_transitions_t() :: [
  transition_t() | incomplete_transition_t() | empty_t()
]
Link to this type

ok_t()

View Source
ok_t() :: {atom(), list(), any()}
Link to this type

result_t()

View Source
result_t() :: ok_t() | error_t()
Link to this type

state_t()

View Source
state_t() :: atom()
Link to this type

symbolic_transformer_t()

View Source
symbolic_transformer_t() :: transformer_t() | atom()
Link to this type

symbolic_updater_t()

View Source
symbolic_updater_t() :: updater_t() | atom()
Link to this type

transformer_t()

View Source
transformer_t() :: (match_t() -> any())
Link to this type

transition_map_t()

View Source
transition_map_t() :: map()
Link to this type

transition_t()

View Source
transition_t() :: {trigger_t(), transformer_t(), updater_t(), state_t()}
Link to this type

trigger_t()

View Source
trigger_t() :: true | Regex.t() | (any() -> any())
Link to this type

updater_t()

View Source
updater_t() :: (any(), match_t() -> any())

Link to this section Functions

Link to this function

halt_transfo(_)

View Source
halt_transfo(any()) :: :halt

Convenience transformer function to stop the state machine, can be used with the atom :halt

Link to this function

ident_transfo(arg)

View Source
ident_transfo(match_t()) :: any()

Convenience function to push an input to the output without changing it, can be used with the atom :id in the transformer position of a transition, e.g. {~r{alpha}, :id, fn count, _ -> count + 1 end}

Link to this function

ident_updater(data, _)

View Source
ident_updater(any(), any()) :: any()

Convenience function to not change the data. It can be used with the atom :id in the updater position of a transition, e.g. {~r{alpha}, fn {_, line} -> String.reverse(line), :id}

Link to this function

ignore_input(_)

View Source
ignore_input(any()) :: :ignore

Convenience function to ignore an input, it can be used with the atom :ignore in the transformer position of a transition, e.g. {~r{alpha}, :ignore, fn count, _ -> count + 1 end}