Marionette
- Package
- purescript-marionette
- Repository
- thought2/purescript-marionette
The main module of the marionette
runtime. You need a Controller
and a
Renderer
in addition to the types and functions that are defined in here to
run a state machine program.
#Config Source
type Config msg sta = { exitIf :: msg -> sta -> Boolean, initialMsg :: Maybe msg, onEvent :: ProgramEvent msg sta -> Effect Unit, stateHandler :: sta -> Effect (State sta Aff) }
Type variables:
msg
the message type of your programsta
the state type of your program
Record fields:
exitIf
provides an exit condition to leave the running state machine based on the current message/state combination.initialMsg
useful if the first message event is not triggered by user input.onEvent
lets you observe events that occur inside themarionette
runtime. This is useful for either debugging or other kind of state machine flow analysis.stateHandler
The state implementation that is used by the runtime.
#EventType Source
data EventType msg sta
Possible observable events that may occur inside the marionette
runtime.
Constructors
NewMsg ThreadId msg
EndMsg ThreadId
specific thread triggered by a message event has finished running
NewState ThreadId sta
new state update has been performed and a re-rendering was triggered
Instances
#Program Source
type Program msg sta = { controller :: Controller msg sta, initialState :: sta, renderer :: Renderer msg sta }
Type variables:
msg
message type of your programsta
state type of your program
Record fields:
initialState
value of the initial staterenderer
specifies how state is renderedcontroller
specifies the how the control flow is handled
#ProgramEvent Source
data ProgramEvent msg sta
General program event type that contains a timestamp and a more specific event type.
Constructors
ProgramEvent Instant (EventType msg sta)
Instances
Generic (ProgramEvent msg sta) _
(Show msg, Show sta) => Show (ProgramEvent msg sta)
#defaultConfig Source
defaultConfig :: forall msg sta. Eq sta => Config msg sta
Some defaults for the Config type
#noController Source
noController :: forall msg sta. Controller msg sta
A controller that does nothing. Useful if you just want to render something and the controller is not implemented yet.
#noRenderer Source
noRenderer :: forall msg sta. Renderer msg sta
A renderer that does nothing. Useful if like to run a headless state machine.
new thread is triggered by a message event