aboutsummaryrefslogtreecommitdiff
path: root/src/client/Utils
diff options
context:
space:
mode:
authorJoris2017-09-24 22:14:48 +0200
committerJoris2017-11-07 09:33:01 +0100
commit898e7ed11ab0958fcdaf65b99b33f7b04787630a (patch)
tree8b5ab951c36d7d27550a7c4eaad16bbd2cd0edb1 /src/client/Utils
parent14bdbc8c937f5d0b35c61350dba28cb41c3737cd (diff)
Bootstrap with GHCJS and reflex:
- setup login and logout, - first draft of payment view.
Diffstat (limited to 'src/client/Utils')
-rw-r--r--src/client/Utils/Cmd.elm16
-rw-r--r--src/client/Utils/Dict.elm11
-rw-r--r--src/client/Utils/Either.elm9
-rw-r--r--src/client/Utils/Form.elm11
-rw-r--r--src/client/Utils/Http.elm39
-rw-r--r--src/client/Utils/Json.elm12
-rw-r--r--src/client/Utils/List.elm36
-rw-r--r--src/client/Utils/Search.elm10
-rw-r--r--src/client/Utils/String.elm38
9 files changed, 0 insertions, 182 deletions
diff --git a/src/client/Utils/Cmd.elm b/src/client/Utils/Cmd.elm
deleted file mode 100644
index 5f41cbe..0000000
--- a/src/client/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/Utils/Dict.elm b/src/client/Utils/Dict.elm
deleted file mode 100644
index 7d708e2..0000000
--- a/src/client/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/Utils/Either.elm b/src/client/Utils/Either.elm
deleted file mode 100644
index 275fc8c..0000000
--- a/src/client/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/Utils/Form.elm b/src/client/Utils/Form.elm
deleted file mode 100644
index 6793222..0000000
--- a/src/client/Utils/Form.elm
+++ /dev/null
@@ -1,11 +0,0 @@
-module Utils.Form exposing
- ( fieldAsText
- )
-
-import Form exposing (Form)
-
-fieldAsText : Form a b -> String -> String
-fieldAsText form field =
- Form.getFieldAsString field form
- |> .value
- |> Maybe.withDefault ""
diff --git a/src/client/Utils/Http.elm b/src/client/Utils/Http.elm
deleted file mode 100644
index dd3870a..0000000
--- a/src/client/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/Utils/Json.elm b/src/client/Utils/Json.elm
deleted file mode 100644
index 29e815b..0000000
--- a/src/client/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/Utils/List.elm b/src/client/Utils/List.elm
deleted file mode 100644
index 8e26e85..0000000
--- a/src/client/Utils/List.elm
+++ /dev/null
@@ -1,36 +0,0 @@
-module Utils.List exposing
- ( groupBy
- , mean
- , links
- )
-
-import Dict
-import Maybe.Extra as Maybe
-
-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)
-
-links : List a -> List (a, a)
-links xs =
- let reversed = List.reverse xs
- in List.foldr
- (\x acc ->
- case Maybe.map Tuple.first (List.head acc) of
- Just y ->
- (x, y) :: acc
- _ ->
- acc
- )
- (case reversed of
- x :: y :: _ -> [(y, x)]
- _ -> []
- )
- (List.reverse << List.drop 2 <| reversed)
diff --git a/src/client/Utils/Search.elm b/src/client/Utils/Search.elm
deleted file mode 100644
index 1b70387..0000000
--- a/src/client/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/Utils/String.elm b/src/client/Utils/String.elm
deleted file mode 100644
index 90fe68e..0000000
--- a/src/client/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