Elm中Url.Parser.custom的第一个参数

时间:2019-03-20 05:41:07

标签: elm url-parsing

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 ->
            []

所以:

  1. tipe的目的是什么?
  2. 它具有什么价值重要吗?

1 个答案:

答案 0 :(得分:1)

Evan在以下GitHub问题中解决了此问题:https://github.com/elm/url/issues/6

  

tl; dr:它什么也没做,只是将来使用。