module Update.UpdateTimer ( TimerAction(..) , updateTimer ) where import Time (Time) import Model.Timer (..) import Model.TimerState (..) import Model.Id (..) type TimerAction = Restart | Pause | ToggleRunning | Stop | SetTime Time updateTimer : TimerAction -> Timer -> Timer updateTimer action timer = case action of Restart -> { timer | currentTime <- initTime timer.initialTime , state <- Running } Pause -> { timer | state <- Idle } ToggleRunning -> { timer | state <- if timer.currentTime > 0 && timer.state == Idle then Running else Idle } Stop -> { timer | currentTime <- initTime timer.initialTime , state <- Idle } SetTime time -> let augmentedTime = time + 999 in { timer | initialTime <- augmentedTime , currentTime <- augmentedTime }