| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Acme.TimeMachine
- data Suspension s
- data Universe
- type TimeMachine = Undoable Universe
- undo :: Undoable s ()
- suspend :: Undoable s (Suspension s)
- resume :: Suspension s -> Undoable s ()
- runTM :: TimeMachine a -> IO a
Documentation
data Suspension s Source
Data representing the entire history of the state. Basically a very large list.
type TimeMachine = Undoable Universe Source
Undo-able side-effectful computation monad.
Lets you perform and unperform side-effectful computations (with undo), for example:
main = runTM $ do
liftIO $ putStrLn "Launching the missiles!"
undoYou can also use suspend and resume for a finer control over execution and unexecution:
main = runTM $ do
universe <- suspend
liftIO $ putStrLn "Launching the missiles!"
resume universeBeware! You may accidentally create temporal paradoxes such as:
main = runTM $ do
universe <- suspend
l <- liftIO $ getLine
putStrLn l
unless (null l) $ resume universesuspend :: 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.
runTM :: TimeMachine a -> IO a Source
Execute an undo-able computation.