diff options
Diffstat (limited to 'src/Model.elm')
-rw-r--r-- | src/Model.elm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Model.elm b/src/Model.elm new file mode 100644 index 0000000..6e75c39 --- /dev/null +++ b/src/Model.elm @@ -0,0 +1,40 @@ +module Model exposing + ( Model + , init + , numberOfTimers + ) + +import Dict exposing (Dict) +import Dict +import Time exposing (Time) +import List + +import Msg exposing (Msg) + +import Model.Id exposing (..) +import Model.IdGenerator exposing (..) + +import Timer.Model as Timer exposing (Timer) + +import Edition.Model exposing (Edition) + +type alias Model = + { time : Time + , timers : Dict Id Timer + , timerIdGenerator : IdGenerator + , edition : Maybe Edition + } + +init : Time -> (Model, Cmd Msg) +init initialTime = + let (id, idGenerator) = getId initialIdGenerator + model = + { time = initialTime + , timers = Dict.insert id (Timer.init initialTime) Dict.empty + , timerIdGenerator = idGenerator + , edition = Nothing + } + in (model, Cmd.none) + +numberOfTimers : Model -> Int +numberOfTimers = List.length << Dict.toList << .timers |