I’m trying to extract the first element from the path of a URL using the 0.19 Url.Parser. At first I tried this:
pathHead =
Url.fromString "https://api.keyvalue.xyz/a17766c6/myKey"
|> Maybe.andThen (Url.Parser.parse Url.Parser.string)
but that gives me Nothing
. So I reasoned that maybe I needed to tell the parser that I was expecting a second element to the path, so I tried…
pathHead =
Url.fromString "https://api.keyvalue.xyz/a17766c6/myKey"
|> Maybe.andThen (Url.Parser.parse (Url.Parser.string </> Url.Parser.string))
This fails to compile with a Type Mismatch
but then says that the type I gave it is the same as the type it requires?? Specifically:
Type Mismatch
Line 76, Column 52
The 1st argument to `parse` is not what I expect:
76| |> Maybe.andThen (Url.Parser.parse (Url.Parser.string </> Url.Parser.string))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This argument is:
Url.Parser.Parser (String -> String) String
But `parse` needs the 1st argument to be:
Url.Parser.Parser (String -> String) String
So…
-
What do I do to actually extract the first element of the path?
-
Is this a bug in the compiler’s error message generator?