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

Tuple.pair and some whitespace fixes

parent aa9ad42c
{
"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": [
"src"
],
"exposed-modules": [],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/json": "1.0.0",
"elm/regex": "1.0.0",
"elm/svg": "1.0.0",
"elm/json": "1.0.0"
"elm/time": "1.0.0"
},
"indirect": {
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
......
......@@ -42,7 +42,7 @@ fromArray arr parent =
Array.indexedMap (\idx el -> Node idx el (parent el) []) arr
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 =
......
......@@ -70,8 +70,8 @@ isSorted le list =
-}
differentValue : List a -> List a -> List (Int,a,a)
differentValue xs ys =
List.map2 (,) xs ys
|> List.indexedMap (,)
List.map2 Tuple.pair xs ys
|> List.indexedMap Tuple.pair
|> List.filter (uncurry (/=) << Tuple.second)
|> List.map (\(a,(b,c)) -> (a,b,c))
......@@ -144,7 +144,7 @@ takeWhile prop list =
else []
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
-}
......
module Main exposing (..)
import Html exposing (Html, button, div, text, a, img)
import Html as Html
import Html.Lazy as Html
......@@ -112,7 +114,7 @@ update msg model =
validateIndex arr idx =
Array.get idx arr
|> 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 idx updater array =
......@@ -322,9 +324,9 @@ viewNavigation model =
[ img
[ HA.src "logo_negated.png"
, HA.style
[(,) "height" "2.4em"
,(,) "margin" "-5px -5px"
--,(,) "border" "1px solid red"
[Tuple.pair "height" "2.4em"
,Tuple.pair "margin" "-5px -5px"
--,Tuple.pair "border" "1px solid red"
]
] []
]
......@@ -334,7 +336,7 @@ viewNavigation model =
( if model.flags.showRestart
then (::) <|
noclick <| [ Html.a
[ HA.style [(,) "font-weight" "bold" ]
[ HA.style [Tuple.pair "font-weight" "bold" ]
, HA.href "rails.html"
]
[ MultiLang.text "Restart" "Neu Starten"]
......@@ -344,7 +346,7 @@ viewNavigation model =
[ link (ForRails RailPuzzle.undo) "Undo" "Rückgängig"
, link resetCars "Reset All Cars" "Zurücksetzen"
, noclick <| [ Html.span
[ HA.style [(,) "margin-right" "1em"] ]
[ HA.style [Tuple.pair "margin-right" "1em"] ]
[ Html.text "Puzzle:"]
, net_switcher
]
......
......@@ -157,7 +157,7 @@ update msg model =
Just line ->
model
|> nextTraceCommand 1
|> flip (,) (compileTraceLine line)
|> flip Tuple.pair (compileTraceLine line)
Nothing ->
plain model
StickToBottom b ->
......
......@@ -313,7 +313,7 @@ compile rail_example additional_queries =
Shunt.parentShunt
(Array.map NEL.toList shunts)
(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
|> ListUtils.product directions
......@@ -333,7 +333,7 @@ compile rail_example additional_queries =
trackIndices =
shunts
|> Array.map (NEL.indexedMap always)
|> Array.indexedMap (\i -> NEL.map ((,) i))
|> Array.indexedMap (\i -> NEL.map (Tuple.pair i))
|> Array.map NEL.toList
|> Array.toList
|> List.concat
......
......@@ -268,7 +268,7 @@ exportOptions model =
conflicting_cars : Model -> Int -> RT.Path -> RT.Path -> List (Int,C.Carriage)
conflicting_cars m idx old_path new_path =
Array.toList m.cars
|> List.indexedMap (,) -- get their index
|> List.indexedMap Tuple.pair -- get their index
-- only keep those with different index
|> List.filter (\(i,_) -> i /= idx)
-- only keep those that conflict with the proposed track
......
......@@ -17,7 +17,7 @@ type Command
none : Command
none = Batch []
(!) : a -> List Command -> (a, Command)
(!) a cmds = (a, Batch cmds)
-- (!) : a -> List Command -> (a, Command)
-- (!) a cmds = (a, Batch cmds)
-- vim: ft=elm et ts=2 sw=2
......@@ -298,7 +298,7 @@ layoutRailTreeAt left =
|> shift center -- starting in the junctions center
--
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)
in
......
......@@ -113,7 +113,7 @@ moveCarTo source target =
-- mainCar : Result String Int
mainCar =
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.head -- get first defined entry
|> Maybe.map Tuple.second -- we only need its index
......@@ -225,7 +225,7 @@ compileCarMovements rt cars sm =
parentShunt : Array (List RT.Path) -> List RT.Path -> Maybe Int
parentShunt shunt_array lower =
shunt_array
|> Array.indexedMap (,)
|> Array.indexedMap Tuple.pair
-- only take those shunts which consists of only prefixes for
-- the lower shunt
|> 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
translate delta object =
let
transform =
"translate("
++ (toString delta.x)
++ ","
++ (toString delta.y)
++ ")"
"translate("
++ (toString delta.x)
++ ","
++ (toString delta.y)
++ ")"
in
Svg.g
[ SvgAttr.transform transform ]
......@@ -147,17 +147,18 @@ boundedSvg attributes (bbox, object) =
-}
svgAsymmetricRect : List (Svg.Attribute msg) -> Float -> Float -> Float -> P2D -> Float -> Svg.Svg msg
svgAsymmetricRect attributes width height_above height_below center angle =
let transform =
"rotate("
++ (toString angle)
++ "," ++ (toString center.x)
++ "," ++ (toString center.y)
++ ")"
++ " translate("
++ (toString (width / -2.0))
++ ","
++ (toString (-height_above))
++ ")"
let
transform =
"rotate("
++ (toString angle)
++ "," ++ (toString center.x)
++ "," ++ (toString center.y)
++ ")"
++ " translate("
++ (toString (width / -2.0))
++ ","
++ (toString (-height_above))
++ ")"
in Svg.rect
([ SvgAttr.width (toString width)
, SvgAttr.height (toString <| height_above + height_below)
......@@ -172,12 +173,13 @@ svgCenteredRect attributes width height center angle =
svgCenteredText : List (Svg.Attribute msg) -> String -> P2D -> Float -> Svg.Svg msg
svgCenteredText attributes text center angle =
let transform =
"rotate("
++ (toString angle)
++ "," ++ (toString center.x)
++ "," ++ (toString center.y)
++ ")"
let
transform =
"rotate("
++ (toString angle)
++ "," ++ (toString center.x)
++ "," ++ (toString center.y)
++ ")"
in
Svg.text_
( SvgAttr.x (toString center.x)
......
......@@ -129,7 +129,7 @@ trackWalkDistanceForce t dist =
case (trackWalkDistance t dist) of
E.Right res -> res
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
......
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