From 973a039b54327df74396605410ea9abe19c8a4e7 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 4 Sep 2016 21:21:11 +0200 Subject: Upgrade to elm 0.17.1 --- src/Edition/Model.elm | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/Edition/Model.elm (limited to 'src/Edition/Model.elm') diff --git a/src/Edition/Model.elm b/src/Edition/Model.elm new file mode 100644 index 0000000..5c1b295 --- /dev/null +++ b/src/Edition/Model.elm @@ -0,0 +1,45 @@ +module Edition.Model exposing + ( Edition + , Kind(..) + , newEdition + , keyCodeToChar + , isEmpty + ) + +import String + +import Model.Id exposing (..) +import Model.Keyboard exposing (KeyCode) + +import Edition.Model.Name as NameEdition +import Edition.Model.Time as TimeEdition + +type alias Edition = + { id : Id + , kind : Kind + , chars : List Char + } + +type Kind = + Name + | Time + +newEdition id kind = + { id = id + , kind = kind + , chars = [] + } + +keyCodeToChar : Kind -> KeyCode -> Maybe Char +keyCodeToChar kind = + case kind of + Name -> NameEdition.keyCodeToChar + Time -> TimeEdition.keyCodeToChar + +isEmpty : Edition -> Bool +isEmpty edition = + edition.chars + |> String.fromList + |> String.trim + |> String.length + |> (==) 0 -- cgit v1.2.3