aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Utils')
-rw-r--r--src/client/elm/Utils/Cmd.elm16
-rw-r--r--src/client/elm/Utils/Dict.elm11
-rw-r--r--src/client/elm/Utils/Either.elm9
-rw-r--r--src/client/elm/Utils/Form.elm13
-rw-r--r--src/client/elm/Utils/Http.elm39
-rw-r--r--src/client/elm/Utils/Json.elm12
-rw-r--r--src/client/elm/Utils/List.elm17
-rw-r--r--src/client/elm/Utils/Maybe.elm34
-rw-r--r--src/client/elm/Utils/Search.elm10
-rw-r--r--src/client/elm/Utils/String.elm38
10 files changed, 0 insertions, 199 deletions
diff --git a/src/client/elm/Utils/Cmd.elm b/src/client/elm/Utils/Cmd.elm
deleted file mode 100644
index 5f41cbe..0000000
--- a/src/client/elm/Utils/Cmd.elm
+++ /dev/null
@@ -1,16 +0,0 @@
-module Utils.Cmd exposing
- ( pipeUpdate
- , (:>)
- )
-
-import Platform.Cmd as Cmd
-
-pipeUpdate : (model, Cmd msg) -> (model -> (model, Cmd msg)) -> (model, Cmd msg)
-pipeUpdate (model, cmd) f =
- let (newModel, newCmd) = f model
- in (newModel, Cmd.batch [ cmd, newCmd ])
-
-(:>) : (m, Cmd a) -> (m -> (m, Cmd a)) -> (m, Cmd a)
-(:>) = pipeUpdate
-
-infixl 0 :>
diff --git a/src/client/elm/Utils/Dict.elm b/src/client/elm/Utils/Dict.elm
deleted file mode 100644
index 7d708e2..0000000
--- a/src/client/elm/Utils/Dict.elm
+++ /dev/null
@@ -1,11 +0,0 @@
-module Utils.Dict exposing
- ( mapValues
- )
-
-import Dict as Dict exposing (..)
-
-mapValues : (a -> b) -> Dict comparable a -> Dict comparable b
-mapValues f = Dict.fromList << List.map (onSecond f) << Dict.toList
-
-onSecond : (a -> b) -> (comparable, a) -> (comparable, b)
-onSecond f tuple = case tuple of (x, y) -> (x, f y)
diff --git a/src/client/elm/Utils/Either.elm b/src/client/elm/Utils/Either.elm
deleted file mode 100644
index 275fc8c..0000000
--- a/src/client/elm/Utils/Either.elm
+++ /dev/null
@@ -1,9 +0,0 @@
-module Utils.Either exposing
- ( toMaybeError
- )
-
-toMaybeError : Result a b -> Maybe a
-toMaybeError result =
- case result of
- Ok _ -> Nothing
- Err x -> Just x
diff --git a/src/client/elm/Utils/Form.elm b/src/client/elm/Utils/Form.elm
deleted file mode 100644
index 8d75a32..0000000
--- a/src/client/elm/Utils/Form.elm
+++ /dev/null
@@ -1,13 +0,0 @@
-module Utils.Form exposing
- ( fieldAsText
- )
-
-import Form exposing (Form)
-
-import Model.Payment exposing (Frequency(..))
-
-fieldAsText : Form a b -> String -> String
-fieldAsText form field =
- Form.getFieldAsString field form
- |> .value
- |> Maybe.withDefault ""
diff --git a/src/client/elm/Utils/Http.elm b/src/client/elm/Utils/Http.elm
deleted file mode 100644
index dd3870a..0000000
--- a/src/client/elm/Utils/Http.elm
+++ /dev/null
@@ -1,39 +0,0 @@
-module Utils.Http exposing
- ( jsonRequest
- , request
- , errorKey
- )
-
-import Http exposing (..)
-import Task exposing (..)
-import Json.Decode as Decode exposing (Decoder, Value)
-import Json.Encode as Encode
-
-jsonRequest : String -> String -> Expect a -> (Result Error a -> msg) -> Encode.Value -> Cmd msg
-jsonRequest method url expect handleResult value =
- requestWithBody method url (jsonBody value) expect handleResult
-
-request : String -> String -> Expect a -> (Result Error a -> msg) -> Cmd msg
-request method url = requestWithBody method url emptyBody
-
-requestWithBody : String -> String -> Body -> Expect a -> (Result Error a -> msg) -> Cmd msg
-requestWithBody method url body expect handleResult =
- let req = Http.request
- { method = method
- , headers = []
- , url = url
- , body = body
- , expect = expect
- , timeout = Nothing
- , withCredentials = False
- }
- in send handleResult req
-
-errorKey : Error -> String
-errorKey error =
- case error of
- BadUrl _ -> "BadUrl"
- Timeout -> "Timeout"
- NetworkError -> "NetworkError"
- BadPayload _ _ -> "BadPayload"
- BadStatus response -> response.body
diff --git a/src/client/elm/Utils/Json.elm b/src/client/elm/Utils/Json.elm
deleted file mode 100644
index 29e815b..0000000
--- a/src/client/elm/Utils/Json.elm
+++ /dev/null
@@ -1,12 +0,0 @@
-module Utils.Json exposing
- ( dictDecoder
- )
-
-import Json.Decode as Decode exposing (Decoder)
-import Dict exposing (Dict)
-
-dictDecoder : Decoder comparable -> Decoder a -> Decoder (Dict comparable a)
-dictDecoder keyDecoder valueDecoder =
- Decode.map2 (,) keyDecoder valueDecoder
- |> Decode.list
- |> Decode.map Dict.fromList
diff --git a/src/client/elm/Utils/List.elm b/src/client/elm/Utils/List.elm
deleted file mode 100644
index cc57d9f..0000000
--- a/src/client/elm/Utils/List.elm
+++ /dev/null
@@ -1,17 +0,0 @@
-module Utils.List exposing
- ( groupBy
- , mean
- )
-
-import Dict
-
-groupBy : (a -> comparable) -> List a -> List (comparable, List a)
-groupBy f xs =
- let addItem item dict =
- let groupItems = Dict.get (f item) dict |> Maybe.withDefault []
- in Dict.insert (f item) (item :: groupItems) dict
- in List.foldr addItem Dict.empty xs
- |> Dict.toList
-
-mean : List Int -> Int
-mean xs = (List.sum xs) // (List.length xs)
diff --git a/src/client/elm/Utils/Maybe.elm b/src/client/elm/Utils/Maybe.elm
deleted file mode 100644
index 46456e1..0000000
--- a/src/client/elm/Utils/Maybe.elm
+++ /dev/null
@@ -1,34 +0,0 @@
-module Utils.Maybe exposing
- ( isJust
- , cat
- , toList
- , orElse
- )
-
-isJust : Maybe a -> Bool
-isJust maybe =
- case maybe of
- Just _ -> True
- Nothing -> False
-
-cat : List (Maybe a) -> List a
-cat =
- List.foldr
- (\mb xs ->
- case mb of
- Just x -> x :: xs
- Nothing -> xs
- )
- []
-
-toList : Maybe a -> List a
-toList mb =
- case mb of
- Just a -> [a]
- Nothing -> []
-
-orElse : Maybe a -> Maybe a -> Maybe a
-orElse mb1 mb2 =
- case mb1 of
- Just x -> Just x
- Nothing -> mb2
diff --git a/src/client/elm/Utils/Search.elm b/src/client/elm/Utils/Search.elm
deleted file mode 100644
index 1b70387..0000000
--- a/src/client/elm/Utils/Search.elm
+++ /dev/null
@@ -1,10 +0,0 @@
-module Utils.Search exposing
- ( format
- )
-
-import String
-
-import Utils.String as String
-
-format : String -> String
-format = String.unaccent << String.toLower
diff --git a/src/client/elm/Utils/String.elm b/src/client/elm/Utils/String.elm
deleted file mode 100644
index 90fe68e..0000000
--- a/src/client/elm/Utils/String.elm
+++ /dev/null
@@ -1,38 +0,0 @@
-module Utils.String exposing
- ( unaccent
- )
-
-unaccent : String -> String
-unaccent = String.map unaccentChar
-
-unaccentChar : Char -> Char
-unaccentChar c = case c of
- 'à' -> 'a'
- 'á' -> 'a'
- 'â' -> 'a'
- 'ã' -> 'a'
- 'ä' -> 'a'
- 'ç' -> 'c'
- 'è' -> 'e'
- 'é' -> 'e'
- 'ê' -> 'e'
- 'ë' -> 'e'
- 'ì' -> 'i'
- 'í' -> 'i'
- 'î' -> 'i'
- 'ï' -> 'i'
- 'ñ' -> 'n'
- 'ò' -> 'o'
- 'ó' -> 'o'
- 'ô' -> 'o'
- 'õ' -> 'o'
- 'ö' -> 'o'
- 'š' -> 's'
- 'ù' -> 'u'
- 'ú' -> 'u'
- 'û' -> 'u'
- 'ü' -> 'u'
- 'ý' -> 'y'
- 'ÿ' -> 'y'
- 'ž' -> 'z'
- _ -> c