Created
April 3, 2016 06:45
-
-
Save chuck0523/046a2402401cd4e3573d2bc26bce3221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update : Action -> Model -> Model | |
update action model = | |
case action of | |
Insert -> | |
let newCounter = ( model.nextID, Counter.init 0 ) | |
newCounters = model.counters ++ [ newCounter ] | |
in | |
{ model | | |
counters = newCounters, | |
nextID = model.nextID + 1 | |
} | |
Remove id -> | |
{ model | | |
counters = List.filter (\(counterID, _) -> counterID /= id) model.counters | |
} | |
Modify id counterAction -> | |
let updateCounter (counterID, counterModel) = | |
if counterID == id | |
then (counterID, Counter.update counterAction counterModel) | |
else (counterID, counterModel) | |
in | |
{ model | counters = List.map updateCounter model.counters } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment