summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/elm/Shared/Action/Ports.elm (renamed from src/shared/elm/Action/Ports.elm) | 2 | ||||
-rw-r--r-- | src/shared/elm/Shared/Comm/GoTo.elm (renamed from src/shared/elm/Comm/GoTo.elm) | 2 | ||||
-rw-r--r-- | src/shared/elm/Shared/Struct/Flags.elm (renamed from src/shared/elm/Struct/Flags.elm) | 2 | ||||
-rw-r--r-- | src/shared/elm/Shared/Update/Sequence.elm | 37 | ||||
-rw-r--r-- | src/shared/elm/Shared/Util/Array.elm (renamed from src/shared/elm/Util/Array.elm) | 2 | ||||
-rw-r--r-- | src/shared/elm/Shared/Util/Html.elm (renamed from src/shared/elm/Util/Html.elm) | 2 | ||||
-rw-r--r-- | src/shared/elm/Shared/Util/Http.elm (renamed from src/shared/elm/Util/Http.elm) | 2 | ||||
-rw-r--r-- | src/shared/elm/Shared/Util/List.elm (renamed from src/shared/elm/Util/List.elm) | 11 |
8 files changed, 47 insertions, 13 deletions
diff --git a/src/shared/elm/Action/Ports.elm b/src/shared/elm/Shared/Action/Ports.elm index 8da9bac..0f87da5 100644 --- a/src/shared/elm/Action/Ports.elm +++ b/src/shared/elm/Shared/Action/Ports.elm @@ -1,4 +1,4 @@ -port module Action.Ports exposing (..) +port module Shared.Action.Ports exposing (..) port store_new_session : (String, String) -> (Cmd msg) port reset_session : () -> (Cmd msg) diff --git a/src/shared/elm/Comm/GoTo.elm b/src/shared/elm/Shared/Comm/GoTo.elm index ea8d7af..19e9619 100644 --- a/src/shared/elm/Comm/GoTo.elm +++ b/src/shared/elm/Shared/Comm/GoTo.elm @@ -1,4 +1,4 @@ -module Comm.GoTo exposing (decode) +module Shared.Comm.GoTo exposing (decode) -- Elm ------------------------------------------------------------------------- import Json.Decode diff --git a/src/shared/elm/Struct/Flags.elm b/src/shared/elm/Shared/Struct/Flags.elm index 475d1f2..f57362e 100644 --- a/src/shared/elm/Struct/Flags.elm +++ b/src/shared/elm/Shared/Struct/Flags.elm @@ -1,4 +1,4 @@ -module Struct.Flags exposing +module Shared.Struct.Flags exposing ( Type, maybe_get_parameter, diff --git a/src/shared/elm/Shared/Update/Sequence.elm b/src/shared/elm/Shared/Update/Sequence.elm new file mode 100644 index 0000000..ff33ae4 --- /dev/null +++ b/src/shared/elm/Shared/Update/Sequence.elm @@ -0,0 +1,37 @@ +module Shared.Update.Sequence exposing (sequence) + +-- Elm ------------------------------------------------------------------------- +import List + +-- Local Module ---------------------------------------------------------------- +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +sequence_step : ( + (Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))) + -> (Struct.Model.Type, (List (Cmd Struct.Event.Type))) + -> (Struct.Model.Type, (List (Cmd Struct.Event.Type))) + ) +sequence_step action (model, cmd_list) = + let (next_model, new_cmd) = (action model) in + case new_cmd of + Cmd.none -> (next_model, cmd_list) + _ -> (next_model, (cmd_list ++ new_cmds)) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +sequence : ( + (List + (Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))) + ) + -> (Struct.Model.Type, (Cmd Struct.Event.Type)) + ) +sequence actions model = + let (final_model, cmds) = (List.foldr (sequence_step) (model, []) actions) in + case cmds of + [] -> (final_model, Cmd.none) + [cmd] -> (final_model, cmd) + _ -> (final_model, (Cmd.batch cmds)) diff --git a/src/shared/elm/Util/Array.elm b/src/shared/elm/Shared/Util/Array.elm index 26d13f6..234b4c4 100644 --- a/src/shared/elm/Util/Array.elm +++ b/src/shared/elm/Shared/Util/Array.elm @@ -1,4 +1,4 @@ -module Util.Array exposing +module Shared.Util.Array exposing ( update, update_unsafe, diff --git a/src/shared/elm/Util/Html.elm b/src/shared/elm/Shared/Util/Html.elm index 42eadba..8b803f7 100644 --- a/src/shared/elm/Util/Html.elm +++ b/src/shared/elm/Shared/Util/Html.elm @@ -1,4 +1,4 @@ -module Util.Html exposing (nothing) +module Shared.Util.Html exposing (nothing) import Html diff --git a/src/shared/elm/Util/Http.elm b/src/shared/elm/Shared/Util/Http.elm index c098dc7..2e57819 100644 --- a/src/shared/elm/Util/Http.elm +++ b/src/shared/elm/Shared/Util/Http.elm @@ -1,4 +1,4 @@ -module Util.Http exposing (error_to_string) +module Shared.Util.Http exposing (error_to_string) import Http diff --git a/src/shared/elm/Util/List.elm b/src/shared/elm/Shared/Util/List.elm index 829dd3e..6a22a5a 100644 --- a/src/shared/elm/Util/List.elm +++ b/src/shared/elm/Shared/Util/List.elm @@ -1,4 +1,4 @@ -module Util.List exposing (..) +module Shared.Util.List exposing (..) import Set @@ -6,12 +6,9 @@ import List pop : List a -> (Maybe (a, List a)) pop l = - case - ((List.head l), (List.tail l)) - of - (Nothing, _) -> Nothing - (_ , Nothing) -> Nothing - ((Just head), (Just tail)) -> (Just (head, tail)) + case l of + (head :: tail) -> (Just (head, tail)) + [] -> Nothing get_first : (a -> Bool) -> (List a) -> (Maybe a) get_first fun list = |