module Update.UpdateTimerEdition ( updateTimerEdition , TimerEditionAction(..) ) where import Char (..) import Model.TimerEdition (..) import Utils.List (..) type TimerEditionAction = DeleteLast | AddNumber KeyCode updateTimerEdition : TimerEditionAction -> TimerEdition -> TimerEdition updateTimerEdition action timerEdition = case action of DeleteLast -> case maybeTail timerEdition.numbers of Just tailNumbers -> { timerEdition | numbers <- tailNumbers } Nothing -> timerEdition AddNumber keyCode -> case keyCodeToNumberChar keyCode of Just char -> if isDigit char then { timerEdition | numbers <- char :: timerEdition.numbers } else timerEdition Nothing -> timerEdition