davidcavazos/parser/1.2.0

NOTE: the latest version is 7.0.0

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 1.2.0; Software Heritage has not archived the repo; no fork with tag 1.2.0 found (60 same-name repos checked); no cached copy. Use another version.

Details

Parser.Common

Common and other useful parsers.

Common

int : Parser Int

Gets an integer value as an Int.

import Parser exposing (parse)


parse "123" int --> Ok 123


parse "-123" int --> Ok -123


parse "abc" int
    |> Result.mapError .message
--> Err "expected a digit [0-9], but got 'a' instead"
number : Parser Float

Gets a decimal value as a Float.

import Parser exposing (parse)


parse "12" number --> Ok 12.0


parse "12." number --> Ok 12.0


parse "12.34" number --> Ok 12.34


parse ".12" number --> Ok 0.12


parse "-12.34" number --> Ok -12.34


parse "-.12" number --> Ok -0.12


parse "." number
    |> Result.mapError .message
--> Err "expected a digit [0-9], but got '.' instead"


parse "abc" number
    |> Result.mapError .message
--> Err "expected a digit [0-9], but got 'a' instead"