Module

Elmish.TimeMachine.History

Package
purescript-elmish-time-machine
Repository
mcordova47/purescript-elmish-time-machine

#Event Source

type Event msg s = (Message msg) /\ s

Represents a pairing of a given state with the message that led to it

#History Source

newtype History msg s

A zipper type that allows easy traversal through pairs of states and messages in an Elmish UI

#IndexedEvent Source

type IndexedEvent msg s = { index :: Int, message :: Message msg, state :: s }

A record representing a given state, its corresponding message, along with its distance from the present (in "steps" where past events are negative integers and future events are positive)

#Message Source

data Message msg

Initial states have no associated previous message, so it helps to have a type that wraps either an "initial state" message or the latest message which led to the current state

#formatMessage Source

formatMessage :: forall msg. Boolean -> Message msg -> String

Formats a message (using its JS representation) E.g. SetFoo2 {"value0": 1}

#formatState Source

formatState :: forall a. a -> String

Formats a given state by JSON.stringifying it

#future Source

future :: forall msg s. History msg s -> Array (IndexedEvent msg s)

Gets an array of the future state/message pairs, along with its index (or distance from the present), ordered chronologically

#hasFuture Source

hasFuture :: forall msg s. History msg s -> Boolean

Returns true iff there is a nonempty future

#hasPast Source

hasPast :: forall msg s. History msg s -> Boolean

Returns true iff there is a nonempty past

#init Source

init :: forall msg s. s -> History msg s

Initializes the History type with a current state

#jump Source

jump :: forall msg s. Int -> History msg s -> History msg s

Jumps to a certain index, i.e. by a certain number of steps forward or backwards

#latestMessage Source

latestMessage :: forall msg s. History msg s -> Message msg

Gets the latest message

#past Source

past :: forall msg s. History msg s -> Array (IndexedEvent msg s)

Gets an array of the past state/message pairs, along with its index (or distance from the present), ordered chronologically

#present Source

present :: forall msg s. History msg s -> Event msg s

Gets the current state paired with the latest message

#presentState Source

presentState :: forall msg s. History msg s -> s

Gets the current state

#redo Source

redo :: forall msg s. History msg s -> History msg s

Steps forward one event into the future No-op if there is no future

#track Source

track :: forall msg s. History msg s -> msg -> s -> History msg s

Adds a new event to the history, emptying out the future events

#undo Source

undo :: forall msg s. History msg s -> History msg s

Steps back one event into the past No-op if there is no past