aboutsummaryrefslogtreecommitdiffstats
path: root/style-generator/src/Lib.elm
diff options
context:
space:
mode:
Diffstat (limited to 'style-generator/src/Lib.elm')
-rw-r--r--style-generator/src/Lib.elm101
1 files changed, 101 insertions, 0 deletions
diff --git a/style-generator/src/Lib.elm b/style-generator/src/Lib.elm
new file mode 100644
index 0000000..32692cf
--- /dev/null
+++ b/style-generator/src/Lib.elm
@@ -0,0 +1,101 @@
+module Lib exposing (bare, eName, eValue, expressionNs, false, float, floats, get, int, layerNs, pipelineCall, pipelineMultiCall, sourceNs, str, styleNs, todo, true, zoom)
+
+import MyElm.Advanced as Advanced
+import MyElm.Syntax as Elm exposing (Expression)
+
+
+styleNs =
+ [ "Mapbox", "Style" ]
+
+
+layerNs =
+ [ "Mapbox", "Layer" ]
+
+
+expressionNs =
+ [ "Mapbox", "Expression" ]
+
+
+sourceNs =
+ [ "Mapbox", "Source" ]
+
+
+eName name =
+ Advanced.aliasedName { modulePath = expressionNs, aliasName = "E", name = name, typeName = Nothing }
+
+
+bare =
+ Advanced.exposedName expressionNs
+
+
+zoom : Expression
+zoom =
+ Elm.call0 (eName "zoom")
+
+
+true : Expression
+true =
+ Elm.call0 (bare "true")
+
+
+false : Expression
+false =
+ Elm.call0 (bare "false")
+
+
+float : Expression -> Expression
+float =
+ Elm.call1 (bare "float")
+
+
+floats : Expression -> Expression
+floats =
+ Elm.call1 (eName "floats")
+
+
+int : Expression -> Expression
+int =
+ Elm.call1 (bare "int")
+
+
+str : Expression -> Expression
+str =
+ Elm.call1 (bare "str")
+
+
+eValue : String -> Expression
+eValue =
+ eName >> Elm.call0
+
+
+get : Expression -> Expression
+get =
+ Elm.call1 (eName "get")
+
+
+todo : String -> Expression
+todo msg =
+ Elm.call1 (Elm.valueName [ "Debug" ] "todo") (Elm.string msg)
+
+
+pipelineCall : String -> List Expression -> Expression
+pipelineCall name args =
+ case args of
+ fst :: rest ->
+ Elm.call2 (Elm.local "|>")
+ fst
+ (Elm.calln (eName name) rest)
+
+ _ ->
+ todo <| "Wrong number of arguments passed to E." ++ name
+
+
+pipelineMultiCall : String -> List Expression -> Expression
+pipelineMultiCall name args =
+ case args of
+ fst :: rest ->
+ List.map (Elm.call1 (eName name)) rest
+ |> List.foldl (\a b -> Elm.call2 (Elm.local "|>") b a) fst
+
+ _ ->
+ todo <| "Wrong number of arguments passed to E." ++ name