Skip to content

Commit ac475ce

Browse files
committed
Fix variable shadowing and moved imports in Elm code
1 parent cb81d4c commit ac475ce

File tree

4 files changed

+38
-33
lines changed

4 files changed

+38
-33
lines changed

src/frontend/Main.elm

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Session
1616
import Session.Query as Query
1717
import Session.Status exposing (Status(..))
1818
import Task
19+
import Url.Parser as Parser
1920
import Utils.App as App
2021
import Utils.OneOrMore as OneOrMore
2122
import Version
@@ -76,7 +77,7 @@ subscriptions model =
7677
-- NAVIGATION
7778

7879

79-
onNavigation : Browser.Url -> Msg
80+
onNavigation : Parser.Url -> Msg
8081
onNavigation url =
8182
ReactToUrl (Route.fromUrl url)
8283

src/frontend/Page/Docs.elm

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,17 @@ viewSidebar metadata allDocs query =
153153

154154

155155
viewSidebarModules : Metadata -> List Docs.Module -> String -> Html Msg
156-
viewSidebarModules metadata docs query =
156+
viewSidebarModules metadata modules query =
157157
if String.isEmpty query then
158158
let
159159
viewEntry docs =
160160
li [] [ viewModuleLink metadata docs.name ]
161161
in
162-
ul [] (List.map viewEntry docs)
162+
ul [] (List.map viewEntry modules)
163163

164164
else
165165
ul [] <|
166-
List.filterMap (viewSearchItem metadata (String.toLower query)) docs
166+
List.filterMap (viewSearchItem metadata (String.toLower query)) modules
167167

168168

169169
viewSearchItem : Metadata -> String -> Docs.Module -> Maybe (Html Msg)

src/frontend/Page/Docs/Block.elm

+13-13
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ type alias TypeNameDict =
172172
makeInfo : String -> String -> Route.Version -> String -> List Docs.Module -> Info
173173
makeInfo user project version moduleName docsList =
174174
let
175-
addUnion moduleName union docs =
176-
Dict.insert (moduleName ++ "." ++ union.name) (moduleName, union.name) docs
175+
addUnion home union docs =
176+
Dict.insert (home ++ "." ++ union.name) (home, union.name) docs
177177

178178
addModule docs dict =
179179
List.foldl (addUnion docs.name) dict docs.unions
@@ -303,8 +303,8 @@ toLines info context tipe =
303303

304304
Type.Record (f :: fs) extension ->
305305
let
306-
toLns ( field, tipe ) =
307-
( field, toLines info Other tipe )
306+
toLns ( field, fieldType ) =
307+
( field, toLines info Other fieldType )
308308
in
309309
case extension of
310310
Nothing ->
@@ -648,26 +648,26 @@ toOneLine chunkWidth chunk one entries =
648648

649649

650650
toMoreLines : MoreSettings a msg -> a -> List a -> Lines (Line msg)
651-
toMoreLines {open, sep, close, openIndent, sepIndent, toLines} x xs =
651+
toMoreLines s x xs =
652652
let
653653
(OneOrMore firstLine firstRest) =
654-
toLines x
654+
s.toLines x
655655

656656
openIndentation =
657-
text (String.repeat openIndent " ")
657+
text (String.repeat s.openIndent " ")
658658

659659
sepIndentation =
660-
text (String.repeat sepIndent " ")
660+
text (String.repeat s.sepIndent " ")
661661

662-
toChunk (OneOrMore x xs) =
663-
(sep :: x) :: List.map ((::) sepIndentation) xs
662+
toChunk (OneOrMore y ys) =
663+
(s.sep :: y) :: List.map ((::) sepIndentation) ys
664664

665665
otherLines =
666666
List.map ((::) openIndentation) firstRest
667-
++ List.concatMap (toChunk << toLines) xs
667+
++ List.concatMap (toChunk << s.toLines) xs
668668
in
669-
More (open ++ firstLine) <|
670-
case close of
669+
More (s.open ++ firstLine) <|
670+
case s.close of
671671
Nothing ->
672672
otherLines
673673

src/frontend/Route.elm

+20-16
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ module Route exposing
1111
)
1212

1313

14-
import Browser
1514
import Url
16-
import Url.Parser exposing (Parser, (</>), custom, fragment, map, oneOf, parsePath, s, top)
15+
import Url.Parser as Parser exposing (Parser, (</>), custom, fragment, map, oneOf, s, top)
1716
import Version
1817

1918

@@ -65,35 +64,40 @@ getHash info =
6564
-- LOCATION TO ROUTE
6665

6766

68-
fromUrl : Browser.Url -> Route
67+
fromUrl : Parser.Url -> Route
6968
fromUrl url =
70-
parsePath parser NotFound url
69+
case Parser.parse parser url of
70+
Nothing ->
71+
NotFound (Parser.fromUrl url)
72+
73+
Just route ->
74+
route
7175

7276

7377
parser : Parser (Route -> a) a
7478
parser =
7579
oneOf
7680
[ map Home <| top
77-
, map User <| s "packages" </> user
78-
, map Package <| s "packages" </> user </> project
79-
, map Version <| s "packages" </> user </> project </> version </> versionInfo
81+
, map User <| s "packages" </> user_
82+
, map Package <| s "packages" </> user_ </> project_
83+
, map Version <| s "packages" </> user_ </> project_ </> version_ </> versionInfo
8084
, map Guidelines <| s "help" </> s "design-guidelines"
8185
, map DocsHelp <| s "help" </> s "docs"
8286
]
8387

8488

85-
user : Parser (String -> a) a
86-
user =
89+
user_ : Parser (String -> a) a
90+
user_ =
8791
custom "USER" Just
8892

8993

90-
project : Parser (String -> a) a
91-
project =
94+
project_ : Parser (String -> a) a
95+
project_ =
9296
custom "PROJECT" Just
9397

9498

95-
version : Parser (Version -> a) a
96-
version =
99+
version_ : Parser (Version -> a) a
100+
version_ =
97101
custom "VERSION" <| \string ->
98102
if string == "latest" then
99103
Just Latest
@@ -105,12 +109,12 @@ versionInfo : Parser (VersionInfo -> a) a
105109
versionInfo =
106110
oneOf
107111
[ map Readme top
108-
, map Module (moduleName </> fragment identity)
112+
, map Module (moduleName_ </> fragment identity)
109113
]
110114

111115

112-
moduleName : Parser (String -> a) a
113-
moduleName =
116+
moduleName_ : Parser (String -> a) a
117+
moduleName_ =
114118
custom "MODULE" (Just << String.replace "-" ".")
115119

116120

0 commit comments

Comments
 (0)