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/Model/Edition/Edition.elm | 44 --------------------------------- src/Model/Edition/NameEdition.elm | 18 -------------- src/Model/Edition/TimeEdition.elm | 52 --------------------------------------- src/Model/Id.elm | 4 +-- src/Model/IdGenerator.elm | 6 ++--- src/Model/Keyboard.elm | 5 ++++ src/Model/Model.elm | 34 ------------------------- src/Model/Position.elm | 4 +-- src/Model/Timer.elm | 27 -------------------- src/Model/TimerState.elm | 8 ------ 10 files changed, 12 insertions(+), 190 deletions(-) delete mode 100644 src/Model/Edition/Edition.elm delete mode 100644 src/Model/Edition/NameEdition.elm delete mode 100644 src/Model/Edition/TimeEdition.elm create mode 100644 src/Model/Keyboard.elm delete mode 100644 src/Model/Model.elm delete mode 100644 src/Model/Timer.elm delete mode 100644 src/Model/TimerState.elm (limited to 'src/Model') diff --git a/src/Model/Edition/Edition.elm b/src/Model/Edition/Edition.elm deleted file mode 100644 index 9a28253..0000000 --- a/src/Model/Edition/Edition.elm +++ /dev/null @@ -1,44 +0,0 @@ -module Model.Edition.Edition - ( Edition - , Kind(..) - , newEdition - , keyCodeToChar - , isEmpty - ) where - -import Keyboard exposing (KeyCode) -import String - -import Model.Id exposing (..) -import Model.Edition.NameEdition as NameEdition -import Model.Edition.TimeEdition 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 diff --git a/src/Model/Edition/NameEdition.elm b/src/Model/Edition/NameEdition.elm deleted file mode 100644 index be7c6b3..0000000 --- a/src/Model/Edition/NameEdition.elm +++ /dev/null @@ -1,18 +0,0 @@ -module Model.Edition.NameEdition - ( keyCodeToChar - , renderNameEdition - ) where - -import Char -import Keyboard exposing (KeyCode) -import String -import List - -keyCodeToChar : KeyCode -> Maybe Char -keyCodeToChar = Just << Char.fromCode - -renderNameEdition : List Char -> String -renderNameEdition chars = - chars - |> List.reverse - |> String.fromList diff --git a/src/Model/Edition/TimeEdition.elm b/src/Model/Edition/TimeEdition.elm deleted file mode 100644 index 3b70c3d..0000000 --- a/src/Model/Edition/TimeEdition.elm +++ /dev/null @@ -1,52 +0,0 @@ -module Model.Edition.TimeEdition - ( keyCodeToChar - , toTime - , toMinutesAndSeconds - ) where - -import Time exposing (Time) -import List -import Array -import String -import Keyboard exposing (KeyCode) -import Char - -import Utils.List exposing (..) -import Utils.Maybe exposing (..) - -keyCodeToChar : KeyCode -> Maybe Char -keyCodeToChar code = - let char = Char.fromCode code - in if Char.isDigit char - then Just char - else Nothing - -toTime : List Char -> Time -toTime numbers = - numbers - |> toMinutesAndSeconds - |> \(a, b) -> (stringToInt a, stringToInt b) - |> \(minutes, seconds) -> (toFloat minutes) * 60 * 1000 + (toFloat seconds) * 1000 - -toMinutesAndSeconds : List Char -> (String, String) -toMinutesAndSeconds numbers = - numbers - |> List.take 4 - |> List.reverse - |> completeBegin '0' 4 - |> splitAt 2 - |> \(a, b) -> (String.fromList a, String.fromList b) - -completeBegin : a -> Int -> List a -> List a -completeBegin x count xs = - let length = List.length xs - in List.append (repeat (count - length) x) xs - -stringToInt : String -> Int -stringToInt str = - str - |> String.toInt - |> \res -> - case res of - Ok n -> n - Err _ -> 0 diff --git a/src/Model/Id.elm b/src/Model/Id.elm index c416804..f71b71e 100644 --- a/src/Model/Id.elm +++ b/src/Model/Id.elm @@ -1,5 +1,5 @@ -module Model.Id +module Model.Id exposing ( Id - ) where + ) type alias Id = Int diff --git a/src/Model/IdGenerator.elm b/src/Model/IdGenerator.elm index 9001191..f3eefad 100644 --- a/src/Model/IdGenerator.elm +++ b/src/Model/IdGenerator.elm @@ -1,8 +1,8 @@ -module Model.IdGenerator +module Model.IdGenerator exposing ( IdGenerator , initialIdGenerator , getId - ) where + ) import Model.Id exposing (..) @@ -17,5 +17,5 @@ initialIdGenerator = getId : IdGenerator -> (Id, IdGenerator) getId idGenerator = ( idGenerator.counter - , { idGenerator | counter <- idGenerator.counter + 1 } + , { idGenerator | counter = idGenerator.counter + 1 } ) diff --git a/src/Model/Keyboard.elm b/src/Model/Keyboard.elm new file mode 100644 index 0000000..7649a56 --- /dev/null +++ b/src/Model/Keyboard.elm @@ -0,0 +1,5 @@ +module Model.Keyboard exposing + ( KeyCode + ) + +type alias KeyCode = Int diff --git a/src/Model/Model.elm b/src/Model/Model.elm deleted file mode 100644 index a660b16..0000000 --- a/src/Model/Model.elm +++ /dev/null @@ -1,34 +0,0 @@ -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 diff --git a/src/Model/Position.elm b/src/Model/Position.elm index d15e853..12d2f9b 100644 --- a/src/Model/Position.elm +++ b/src/Model/Position.elm @@ -1,6 +1,6 @@ -module Model.Position +module Model.Position exposing ( positionEncoder - ) where + ) import Json.Encode exposing (..) diff --git a/src/Model/Timer.elm b/src/Model/Timer.elm deleted file mode 100644 index 51d293d..0000000 --- a/src/Model/Timer.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Model.Timer - ( Timer - , initialTimer - ) where - -import List -import Time exposing (Time) - -import Model.TimerState exposing (..) - -type alias Timer = - { creationTime : Time - , name : Maybe String - , initialTime : Time - , currentTime : Time - , state : TimerState - } - -initialTimer : Time -> Timer -initialTimer creationTime = - let initialTime = 5 * 60 * 1000 - in { creationTime = creationTime - , name = Nothing - , initialTime = initialTime - , currentTime = initialTime - , state = Idle - } diff --git a/src/Model/TimerState.elm b/src/Model/TimerState.elm deleted file mode 100644 index dbbcb80..0000000 --- a/src/Model/TimerState.elm +++ /dev/null @@ -1,8 +0,0 @@ -module Model.TimerState - ( TimerState(..) - ) where - -type TimerState = - Idle - | Running - | Ringing -- cgit v1.2.3