Bogdanp/elm-combine/2.0.2

NOTE: this package is not compatible with Elm 0.19.1

Combine.Infix

This module provides infix versions of various functions from the Combine module.

Transforming Parsers

(<$>) : (res -> res_) -> Parser res -> Parser res_

Synonym for Combine.map.

(<$) : res -> Parser x -> Parser res

Variant of Combine.map that ignores the Parser's result.

(<?>) : Parser res -> String -> Parser res

Variant of Combine.mapError that replaces the Parser's error with a List of a single string.

parse (string "a" <?> "gimme an 'a'") "b" ==
  (Err ["gimme an 'a'"], { input = "b", position = 0 })

Chaining Parsers

(<*>) : Parser (res -> res_) -> Parser res -> Parser res_

Synonym for Combine.andMap.

(*>) : Parser x -> Parser res -> Parser res

Join two parsers, ignoring the result of the one on the left.

unprefix : Parser String
unprefix = string ">" *> while ((==) ' ') *> while ((/=) ' ')


parse unprefix "> a" == (Ok "a", { input = "", position = 3 })
(<*) : Parser res -> Parser x -> Parser res

Join two parsers, ignoring the result of the one on the right.

unsuffix : Parser String
unsuffix = regex "[a-z]" <* regex "[!?]"


parse unsuffix "a!" == (Ok "a", { input = "", position = 2 })

Parsers

(<|>) : Parser res -> Parser res -> Parser res

Synonym for or.