Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First argument for Url.Parser.custom in Elm

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?
like image 805
davetapley Avatar asked Mar 20 '19 05:03

davetapley


1 Answers

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.

like image 166
chriscberks Avatar answered Sep 20 '22 17:09

chriscberks