Commit 9411d922 authored by Thorsten Wißmann's avatar Thorsten Wißmann 🐧
Browse files

Tuple.pair and some whitespace fixes

parent aa9ad42c
{ {
"type": "application", "type": "application",
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [ "source-directories": [
"src" "src"
], ],
"exposed-modules": [],
"elm-version": "0.19.1", "elm-version": "0.19.1",
"dependencies": { "dependencies": {
"direct": { "direct": {
"elm/browser": "1.0.0", "elm/browser": "1.0.0",
"elm/core": "1.0.0", "elm/core": "1.0.0",
"elm/html": "1.0.0", "elm/html": "1.0.0",
"elm/json": "1.0.0",
"elm/regex": "1.0.0",
"elm/svg": "1.0.0", "elm/svg": "1.0.0",
"elm/json": "1.0.0" "elm/time": "1.0.0"
}, },
"indirect": { "indirect": {
"elm/time": "1.0.0",
"elm/url": "1.0.0", "elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0" "elm/virtual-dom": "1.0.0"
} }
......
...@@ -42,7 +42,7 @@ fromArray arr parent = ...@@ -42,7 +42,7 @@ fromArray arr parent =
Array.indexedMap (\idx el -> Node idx el (parent el) []) arr Array.indexedMap (\idx el -> Node idx el (parent el) []) arr
hasFst : (Maybe x, b) -> Maybe (x,b) hasFst : (Maybe x, b) -> Maybe (x,b)
hasFst (maybe_a, b) = Maybe.map (flip (,) b) maybe_a hasFst (maybe_a, b) = Maybe.map (flip Tuple.pair b) maybe_a
registerAtParents : List (Int, Int) -- List of parent,child pairs registerAtParents : List (Int, Int) -- List of parent,child pairs
registerAtParents = registerAtParents =
......
...@@ -70,8 +70,8 @@ isSorted le list = ...@@ -70,8 +70,8 @@ isSorted le list =
-} -}
differentValue : List a -> List a -> List (Int,a,a) differentValue : List a -> List a -> List (Int,a,a)
differentValue xs ys = differentValue xs ys =
List.map2 (,) xs ys List.map2 Tuple.pair xs ys
|> List.indexedMap (,) |> List.indexedMap Tuple.pair
|> List.filter (uncurry (/=) << Tuple.second) |> List.filter (uncurry (/=) << Tuple.second)
|> List.map (\(a,(b,c)) -> (a,b,c)) |> List.map (\(a,(b,c)) -> (a,b,c))
...@@ -144,7 +144,7 @@ takeWhile prop list = ...@@ -144,7 +144,7 @@ takeWhile prop list =
else [] else []
product : List a -> List b -> List (a,b) product : List a -> List b -> List (a,b)
product la lb = List.concatMap (\a -> List.map ((,) a) lb) la product la lb = List.concatMap (\a -> List.map (Tuple.pair a) lb) la
{-| find the index of the first occurence of an element in a list {-| find the index of the first occurence of an element in a list
-} -}
......
module Main exposing (..)
import Html exposing (Html, button, div, text, a, img) import Html exposing (Html, button, div, text, a, img)
import Html as Html import Html as Html
import Html.Lazy as Html import Html.Lazy as Html
...@@ -112,7 +114,7 @@ update msg model = ...@@ -112,7 +114,7 @@ update msg model =
validateIndex arr idx = validateIndex arr idx =
Array.get idx arr Array.get idx arr
|> Result.fromMaybe "out of range" |> Result.fromMaybe "out of range"
|> Result.map ((,) idx) -- re-add the idx if it succeeded |> Result.map (Tuple.pair idx) -- re-add the idx if it succeeded
arrayUpdate : Int -> (a -> a) -> (Array a -> Array a) arrayUpdate : Int -> (a -> a) -> (Array a -> Array a)
arrayUpdate idx updater array = arrayUpdate idx updater array =
...@@ -322,9 +324,9 @@ viewNavigation model = ...@@ -322,9 +324,9 @@ viewNavigation model =
[ img [ img
[ HA.src "logo_negated.png" [ HA.src "logo_negated.png"
, HA.style , HA.style
[(,) "height" "2.4em" [Tuple.pair "height" "2.4em"
,(,) "margin" "-5px -5px" ,Tuple.pair "margin" "-5px -5px"
--,(,) "border" "1px solid red" --,Tuple.pair "border" "1px solid red"
] ]
] [] ] []
] ]
...@@ -334,7 +336,7 @@ viewNavigation model = ...@@ -334,7 +336,7 @@ viewNavigation model =
( if model.flags.showRestart ( if model.flags.showRestart
then (::) <| then (::) <|
noclick <| [ Html.a noclick <| [ Html.a
[ HA.style [(,) "font-weight" "bold" ] [ HA.style [Tuple.pair "font-weight" "bold" ]
, HA.href "rails.html" , HA.href "rails.html"
] ]
[ MultiLang.text "Restart" "Neu Starten"] [ MultiLang.text "Restart" "Neu Starten"]
...@@ -344,7 +346,7 @@ viewNavigation model = ...@@ -344,7 +346,7 @@ viewNavigation model =
[ link (ForRails RailPuzzle.undo) "Undo" "Rückgängig" [ link (ForRails RailPuzzle.undo) "Undo" "Rückgängig"
, link resetCars "Reset All Cars" "Zurücksetzen" , link resetCars "Reset All Cars" "Zurücksetzen"
, noclick <| [ Html.span , noclick <| [ Html.span
[ HA.style [(,) "margin-right" "1em"] ] [ HA.style [Tuple.pair "margin-right" "1em"] ]
[ Html.text "Puzzle:"] [ Html.text "Puzzle:"]
, net_switcher , net_switcher
] ]
......
...@@ -157,7 +157,7 @@ update msg model = ...@@ -157,7 +157,7 @@ update msg model =
Just line -> Just line ->
model model
|> nextTraceCommand 1 |> nextTraceCommand 1
|> flip (,) (compileTraceLine line) |> flip Tuple.pair (compileTraceLine line)
Nothing -> Nothing ->
plain model plain model
StickToBottom b -> StickToBottom b ->
......
...@@ -313,7 +313,7 @@ compile rail_example additional_queries = ...@@ -313,7 +313,7 @@ compile rail_example additional_queries =
Shunt.parentShunt Shunt.parentShunt
(Array.map NEL.toList shunts) (Array.map NEL.toList shunts)
(NEL.toList s) -- find its parent (NEL.toList s) -- find its parent
|> Maybe.map ((,) idx) -- and add the index of the shunt |> Maybe.map (Tuple.pair idx) -- and add the index of the shunt
) )
|> List.filterMap identity -- drop all shunts with no parent |> List.filterMap identity -- drop all shunts with no parent
|> ListUtils.product directions |> ListUtils.product directions
...@@ -333,7 +333,7 @@ compile rail_example additional_queries = ...@@ -333,7 +333,7 @@ compile rail_example additional_queries =
trackIndices = trackIndices =
shunts shunts
|> Array.map (NEL.indexedMap always) |> Array.map (NEL.indexedMap always)
|> Array.indexedMap (\i -> NEL.map ((,) i)) |> Array.indexedMap (\i -> NEL.map (Tuple.pair i))
|> Array.map NEL.toList |> Array.map NEL.toList
|> Array.toList |> Array.toList
|> List.concat |> List.concat
......
...@@ -268,7 +268,7 @@ exportOptions model = ...@@ -268,7 +268,7 @@ exportOptions model =
conflicting_cars : Model -> Int -> RT.Path -> RT.Path -> List (Int,C.Carriage) conflicting_cars : Model -> Int -> RT.Path -> RT.Path -> List (Int,C.Carriage)
conflicting_cars m idx old_path new_path = conflicting_cars m idx old_path new_path =
Array.toList m.cars Array.toList m.cars
|> List.indexedMap (,) -- get their index |> List.indexedMap Tuple.pair -- get their index
-- only keep those with different index -- only keep those with different index
|> List.filter (\(i,_) -> i /= idx) |> List.filter (\(i,_) -> i /= idx)
-- only keep those that conflict with the proposed track -- only keep those that conflict with the proposed track
......
...@@ -17,7 +17,7 @@ type Command ...@@ -17,7 +17,7 @@ type Command
none : Command none : Command
none = Batch [] none = Batch []
(!) : a -> List Command -> (a, Command) -- (!) : a -> List Command -> (a, Command)
(!) a cmds = (a, Batch cmds) -- (!) a cmds = (a, Batch cmds)
-- vim: ft=elm et ts=2 sw=2 -- vim: ft=elm et ts=2 sw=2
...@@ -298,7 +298,7 @@ layoutRailTreeAt left = ...@@ -298,7 +298,7 @@ layoutRailTreeAt left =
|> shift center -- starting in the junctions center |> shift center -- starting in the junctions center
-- --
outgoing_angles : List (Float,P2D) outgoing_angles : List (Float,P2D)
outgoing_angles = List.indexedMap (\idx _ -> (,) (idx2angle idx) (idx2point idx)) rts outgoing_angles = List.indexedMap (\idx _ -> Tuple.pair (idx2angle idx) (idx2point idx)) rts
new_arg = Has.setWitness arg (left.angle,left.p,center,outgoing_angles) new_arg = Has.setWitness arg (left.angle,left.p,center,outgoing_angles)
in in
......
...@@ -113,7 +113,7 @@ moveCarTo source target = ...@@ -113,7 +113,7 @@ moveCarTo source target =
-- mainCar : Result String Int -- mainCar : Result String Int
mainCar = mainCar =
source source
|> List.map (\(p,i) -> Maybe.map ((,) p) i) -- move path under the maybe |> List.map (\(p,i) -> Maybe.map (Tuple.pair p) i) -- move path under the maybe
|> List.filterMap identity |> List.filterMap identity
|> List.head -- get first defined entry |> List.head -- get first defined entry
|> Maybe.map Tuple.second -- we only need its index |> Maybe.map Tuple.second -- we only need its index
...@@ -225,7 +225,7 @@ compileCarMovements rt cars sm = ...@@ -225,7 +225,7 @@ compileCarMovements rt cars sm =
parentShunt : Array (List RT.Path) -> List RT.Path -> Maybe Int parentShunt : Array (List RT.Path) -> List RT.Path -> Maybe Int
parentShunt shunt_array lower = parentShunt shunt_array lower =
shunt_array shunt_array
|> Array.indexedMap (,) |> Array.indexedMap Tuple.pair
-- only take those shunts which consists of only prefixes for -- only take those shunts which consists of only prefixes for
-- the lower shunt -- the lower shunt
|> Array.filter (List.all (\p -> List.all (LU.proper_prefix_of p) lower) << Tuple.second) |> Array.filter (List.all (\p -> List.all (LU.proper_prefix_of p) lower) << Tuple.second)
......
...@@ -50,11 +50,11 @@ translate : P2D -> Svg.Svg m -> Svg.Svg m ...@@ -50,11 +50,11 @@ translate : P2D -> Svg.Svg m -> Svg.Svg m
translate delta object = translate delta object =
let let
transform = transform =
"translate(" "translate("
++ (toString delta.x) ++ (toString delta.x)
++ "," ++ ","
++ (toString delta.y) ++ (toString delta.y)
++ ")" ++ ")"
in in
Svg.g Svg.g
[ SvgAttr.transform transform ] [ SvgAttr.transform transform ]
...@@ -147,17 +147,18 @@ boundedSvg attributes (bbox, object) = ...@@ -147,17 +147,18 @@ boundedSvg attributes (bbox, object) =
-} -}
svgAsymmetricRect : List (Svg.Attribute msg) -> Float -> Float -> Float -> P2D -> Float -> Svg.Svg msg svgAsymmetricRect : List (Svg.Attribute msg) -> Float -> Float -> Float -> P2D -> Float -> Svg.Svg msg
svgAsymmetricRect attributes width height_above height_below center angle = svgAsymmetricRect attributes width height_above height_below center angle =
let transform = let
"rotate(" transform =
++ (toString angle) "rotate("
++ "," ++ (toString center.x) ++ (toString angle)
++ "," ++ (toString center.y) ++ "," ++ (toString center.x)
++ ")" ++ "," ++ (toString center.y)
++ " translate(" ++ ")"
++ (toString (width / -2.0)) ++ " translate("
++ "," ++ (toString (width / -2.0))
++ (toString (-height_above)) ++ ","
++ ")" ++ (toString (-height_above))
++ ")"
in Svg.rect in Svg.rect
([ SvgAttr.width (toString width) ([ SvgAttr.width (toString width)
, SvgAttr.height (toString <| height_above + height_below) , SvgAttr.height (toString <| height_above + height_below)
...@@ -172,12 +173,13 @@ svgCenteredRect attributes width height center angle = ...@@ -172,12 +173,13 @@ svgCenteredRect attributes width height center angle =
svgCenteredText : List (Svg.Attribute msg) -> String -> P2D -> Float -> Svg.Svg msg svgCenteredText : List (Svg.Attribute msg) -> String -> P2D -> Float -> Svg.Svg msg
svgCenteredText attributes text center angle = svgCenteredText attributes text center angle =
let transform = let
"rotate(" transform =
++ (toString angle) "rotate("
++ "," ++ (toString center.x) ++ (toString angle)
++ "," ++ (toString center.y) ++ "," ++ (toString center.x)
++ ")" ++ "," ++ (toString center.y)
++ ")"
in in
Svg.text_ Svg.text_
( SvgAttr.x (toString center.x) ( SvgAttr.x (toString center.x)
......
...@@ -129,7 +129,7 @@ trackWalkDistanceForce t dist = ...@@ -129,7 +129,7 @@ trackWalkDistanceForce t dist =
case (trackWalkDistance t dist) of case (trackWalkDistance t dist) of
E.Right res -> res E.Right res -> res
E.Left off -> E.Left off ->
(,) t.a2 <| shift (rad t.a2 dist) t.p2 Tuple.pair t.a2 <| shift (rad t.a2 dist) t.p2
boundingPoints: Float -> TrackA -> List P2D boundingPoints: Float -> TrackA -> List P2D
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment