lazamar / dict-parser / Parser.Dict

fromDict : Dict String a -> Parser a

Create a fast parser for a dictionary.

The parser succeeds with the longest matching key

type Animal
    = Dog
    | Cat
    | Horse

animal : Parser Animal
animal =
    [ ( "doggo", Dog )
    , ( "kitty", Cat )
    , ( "horsey", Horse )
    ]
        |> Dict.fromList
        |> fromDict