Url.Parser.custom
的文档给出了一个示例:
int : Parser (Int -> a) a
int =
custom "NUMBER" String.toInt
但不要指出"NUMBER"
的用途。
我检查了the source,它似乎被捕获为tipe
,但从未使用过:
custom : String -> (String -> Maybe a) -> Parser (a -> b) b
custom tipe stringToSomething =
Parser <| \{ visited, unvisited, params, frag, value } ->
case unvisited of
[] ->
[]
next :: rest ->
case stringToSomething next of
Just nextValue ->
[ State (next :: visited) rest params frag (value nextValue) ]
Nothing ->
[]
所以:
tipe
的目的是什么?答案 0 :(得分:1)
Evan在以下GitHub问题中解决了此问题:https://github.com/elm/url/issues/6
tl; dr:它什么也没做,只是将来使用。