Renamed to lambda-phi/parser. It is published under that name, and new versions come out there.
Versions published as davidcavazos/parser still install under that name. 2 versions of 12 come from the new location (see their notes). 10 versions could not be recovered and cannot be installed.
Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/lambda-phi/parser exists but has no tag 2.0.0; Software Heritage has not archived the repo; no fork with tag 2.0.0 found (60 same-name repos checked); no cached copy. Use another version.
An easy to use general-purpose parser for Elm.
This library aims to provide a clean and intuitive parsing library with good error messages out of the box.
ℹ️ This has been inspired by the elm/parser and dasch/parser libraries.
A good place to start is by defining the data type you want to parse into. Then, it's a good idea to define a function to parse into that data type.
Here's a simple example to parse an (x, y) point, such as (42, 3.14).
import Parser exposing (Parser, char, drop, into, parse, spaces, succeed, take)
import Parser.Common exposing (number)
type alias Point =
{ x : Float
, y : Float
}
point : Parser Point
point =
into "Point"
(succeed Point
|> drop (char '(')
|> drop spaces
|> take number
|> drop spaces
|> drop (char ',')
|> drop spaces
|> take number
|> drop spaces
|> drop (char ')')
)
parse "(2.71, 3.14)" point --> Ok {x = 2.71, y = 3.14}