Created
April 23, 2014 19:39
-
-
Save evancz/11229518 to your computer and use it in GitHub Desktop.
General purpose library for undo/redo. Inspired by David Nolen's talk at Philly ETE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module History where | |
data Step a = Undo | Redo | Checkpoint a | NoCheckpoint a | |
foldp : (a -> b -> b) -> b -> Signal (Step a) -> Signal b | |
-- It could also be interesting to have custom strategies for keeping track | |
-- of history. Maybe you want to have a fixed size stack, infinite stack, | |
-- stack with exponential decay, etc. | |
foldpWith : History b -> (a -> b -> b) -> b -> Signal (Step a) -> Signal b | |
type History a = | |
{ undo : History a -> History a | |
, redo : History a -> History a | |
, add : a -> History a -> History a | |
} | |
finite : Int -> History a | |
finite n = | |
{ undo = ... | |
, redo = ... | |
, add = ... | |
} | |
infinite : History a | |
exponentialDecay : [(Int,Fidelity)] -> History a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment