6

The docs for Url.Parser.custom give an example:

int : Parser (Int -> a) a
int =
  custom "NUMBER" String.toInt

But don't indicate what "NUMBER" is used for.


I checked the source and it seems to be capture as tipe, but never used:

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

So:

  1. What is the purpose of tipe?
  2. Does it matter what value it has?
glennsl
  • 28,186
  • 12
  • 57
  • 75
davetapley
  • 17,000
  • 12
  • 60
  • 86
  • 1
    My guess is that it's meant as a label to aid in debugging parser errors. Since it's not used it seems unlikely to matter. It might just be there to be able to provide better error messages in the future without breaking the API. – glennsl Mar 20 '19 at 09:01

1 Answers1

1

Evan has addressed this in the following GitHub Issue: https://github.com/elm/url/issues/6

tl;dr: It does nothing but is there for future use.

chriscberks
  • 425
  • 2
  • 8