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:
msgthe message type of your programstathe state type of your program
Record fields:
exitIfprovides an exit condition to leave the running state machine based on the current message/state combination.initialMsguseful if the first message event is not triggered by user input.onEventlets you observe events that occur inside themarionetteruntime. This is useful for either debugging or other kind of state machine flow analysis.stateHandlerThe state implementation that is used by the runtime.
#EventType Source
data EventType msg staPossible observable events that may occur inside the marionette runtime.
Constructors
NewMsg ThreadId msgEndMsg ThreadIdspecific thread triggered by a message event has finished running
NewState ThreadId stanew 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:
msgmessage type of your programstastate type of your program
Record fields:
initialStatevalue of the initial staterendererspecifies how state is renderedcontrollerspecifies the how the control flow is handled
#ProgramEvent Source
data ProgramEvent msg staGeneral 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 staSome defaults for the Config type
#noController Source
noController :: forall msg sta. Controller msg staA 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 staA renderer that does nothing. Useful if like to run a headless state machine.
new thread is triggered by a message event