module Nove.Chron where
import Data.List.NonEmpty
-- | History
data History a = History { past :: NonEmpty a , future :: [a] }
-- step backwards in time
before :: History a -> History a
before (History (m :| p : ps) f) = History (p :| ps) (m:f)
before h = h
-- step forwards in time
after :: History a -> History a
after (History p (m:f)) = History (m <| p) f
after h = h
-- go to present
ultimate :: History a -> History a
ultimate h@(History _ []) = h
ultimate h = ultimate $ after h
-- get current
moment :: History a -> a
moment (History (m :| _) _) = m
-- record moment
record :: a -> History a -> History a
record m (History p f) = History (m <| p) f