module Update.UpdateTimer ( TimerAction(..) , updateTimer ) where import Time (Time) import Model.Timer (..) import Model.Id (..) type TimerAction = Restart | Pause | ToggleRunning | Stop | SetTime Time updateTimer : TimerAction -> Timer -> Timer updateTimer action timer = case action of Restart -> { timer | isRunning <- True , currentTime <- initTime timer.initialTime } Pause -> { timer | isRunning <- False } ToggleRunning -> { timer | isRunning <- timer.currentTime > 0.0 && not timer.isRunning } Stop -> { timer | isRunning <- False , currentTime <- initTime timer.initialTime } SetTime time -> let augmentedTime = time + 999 in { timer | initialTime <- augmentedTime , currentTime <- augmentedTime }