FRP with first-class timelines
Playing with time could never go wrong.
From journal entry Undo via timeline-of-actions manipulation:
My master’s thesis was about making timelines/events in FRP first class values which can be modified, and using that to implement things like undo. I think this is a concept which should be explored more, and which would render an FRP-based programming environment super useful, because you could ask “what-if” questions and have a much better interactive development/debugging experience.
Having an FRP implementation in which timelines (Events) are manipulable allows:
- Recording user interaction as actions, rather than states, and allowing the user to replay or manipulate them.
- Implementing Undo/Redo by treating the timeline as a stack you push and pop from.
- Implementing Non-Linear Undo by deleting arbitrary events. Doing this well requires knowing which future actions depend on which actions in the past however. E.g. You don’t want to leave actions that move a circle that was never drawn.
- Implementing advanced and subtle user interactions such as “tapping takes into account the users reaction time”, i.e. if the screen suddenly changes the tap applies to what was there a hundred milliseconds before.
Implementation
Arbitrary timeline editing requires an incremental implementation of FRP if you don’t want to replay all of history. This means that an implementation should focus on using associative, and preferably commutative, folds.