packages feed

acme-timemachine 0.0.0.1 → 0.0.1.0

raw patch · 3 files changed

+12/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Acme.TimeMachine: event :: Undoable s a -> Undoable s a
+ Acme.TimeMachine.Undoable: event :: Undoable s a -> Undoable s a
+ Acme.TimeMachine.Undoable: runUndoable :: Undoable s a -> s -> (s, a)

Files

acme-timemachine.cabal view
@@ -1,6 +1,6 @@ name:                acme-timemachine-version:             0.0.0.1-synopsis:            An easy way to perform and unperform IO actions.+version:             0.0.1.0+synopsis:            An easy way to perform and unperform IO and other stateful actions. description:         When doing some computations with side effects, one might regret the decision to change the state of the universe. This package provides an 'undo' function for such cases, and universe suspension/resuming functions for finer control. license:             BSD3 license-file:        LICENSE
src/Acme/TimeMachine.hs view
@@ -7,7 +7,8 @@ 		undo, 		suspend, 		resume,-        runTM+        runTM,+		event     )     where @@ -21,7 +22,7 @@ data Universe = Universe# (State# RealWorld)  -- | Undo-able side-effectful computation monad.--- Lets you perform and unperform side-effectful computations (with 'undo'), for example:+-- Lets you perform and unperform (with 'undo') computations with side-effects, for example: -- -- > main = runTM $ do -- >     liftIO $ putStrLn "Launching the missiles!"
src/Acme/TimeMachine/Undoable.hs view
@@ -2,10 +2,12 @@ module Acme.TimeMachine.Undoable (         Suspension,         Undoable(..),+		runUndoable,         evalUndoable,         execUndoable,         suspend,         resume,+		event,         undo     )     where@@ -45,6 +47,11 @@ -- | Load the history of a computation, saved by 'suspend'. resume :: Suspension s -> Undoable s () resume l = Undoable $ \_ -> (l, ())++-- | Treat the events occuring inside this block as a single event, that can be undone with a sinle 'undo' invocation.+-- | This will always add exactly one item to the computation's history, even if the block doesn't add any, or even removes some.+event :: Undoable s a -> Undoable s a+event (Undoable f) = Undoable $ \l -> case f l of ~(Suspension s _, r) -> (Suspension s l, r)  -- | Rollback the latest addition to the computation's history. undo :: Undoable s ()