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

Safe HaskellNone
LanguageHaskell2010

Acme.TimeMachine

Synopsis

Documentation

data Suspension s Source

Data representing the entire history of the state. Basically a very large list.

data Universe Source

State of the universe.

Instances

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!"
    undo

You 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 universe

Beware! You may accidentally create temporal paradoxes such as:

main = runTM $ do
    universe <- suspend
    l <- liftIO $ getLine
    putStrLn l
    unless (null l) $ resume universe

undo :: Undoable s () Source

Rollback the latest addition to the computation's history.

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.

runTM :: TimeMachine a -> IO a Source

Execute an undo-able computation.