Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- data Suspension s
- data Undoable s a = Undoable {
- getUndoable :: Suspension s -> (Suspension s, a)
- evalUndoable :: Undoable s a -> s -> a
- execUndoable :: Undoable s a -> s -> s
- suspend :: Undoable s (Suspension s)
- resume :: Suspension s -> Undoable s ()
- undo :: Undoable s ()
Documentation
data Suspension s Source
Data representing the entire history of the state. Basically a very large list.
The undo-able stateful computation monad.
Undoable | |
|
MonadIO TimeMachine | |
MonadState s (Undoable s) | |
Monad (Undoable s) | |
Functor (Undoable s) | |
Applicative (Undoable s) |
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
.