acme-timemachine-0.0.0.0: An easy way to perform and unperform IO actions.

Safe HaskellSafe-Inferred
LanguageHaskell2010

Acme.TimeMachine.Undoable

Synopsis

Documentation

data Suspension s Source

Data representing the entire history of the state.

data Undoable s a Source

The undo-able stateful computation monad.

Constructors

Undoable 

Fields

getUndoable :: Suspension s -> (Suspension s, a)
 

evalUndoable :: Undoable s a -> s -> a Source

Run an undo-able computation and return the result.

>>> evalUndoable (do { return 5 }) 0
5

execUndoable :: Undoable s a -> s -> s Source

Run an undo-able computation and return the resulting state.

>>> execUndoable (do { modify (+3) }) 0
3

suspend :: Undoable s (Suspension s) Source

Save the history of a computation, to be later loaded with resume.

resume :: Suspension s -> Undoable s () Source

Load the history of a computation, saved by suspend.

undo :: Undoable s () Source

Rollback the latest addition to the computation's history.