blob: a660b16644bcd4d3d79a8035b5f337811f3369d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
module Model.Model
( Model
, initialModel
, numberOfTimers
) where
import Dict exposing (Dict)
import Dict
import Time exposing (Time)
import List
import Model.Timer exposing (..)
import Model.Edition.Edition exposing (..)
import Model.Id exposing (..)
import Model.IdGenerator exposing (..)
type alias Model =
{ currentTime : Time
, timers : Dict Id Timer
, timerIdGenerator : IdGenerator
, edition : Maybe Edition
}
initialModel : Time -> Model
initialModel initialTime =
let (id, idGenerator) = getId initialIdGenerator
in { currentTime = initialTime
, timers = Dict.insert id (initialTimer initialTime) Dict.empty
, timerIdGenerator = idGenerator
, edition = Nothing
}
numberOfTimers : Model -> Int
numberOfTimers = List.length << Dict.toList << .timers
|