andre-dietrich/parser-combinators/3.0.2

NOTE: the latest version is 7.1.1

Combine.Char

This module contains Char-specific Parsers.

Avoid using this module if performance is a concern. You can achieve everything that you can do with this module by using Combine.regex, Combine.string or Combine.primitive and, in general, those will be much faster.

Parsers

satisfy : (Char -> Bool) -> Parser s Char

Parse a character matching the predicate.

parse (satisfy ((==) 'a')) "a" ==
-- Ok 'a'


parse (satisfy ((==) 'a')) "b" ==
-- Err ["could not satisfy predicate"]
char : Char -> Parser s Char

Parse an exact character match.

parse (char 'a') "a" ==
-- Ok 'a'


parse (char 'a') "b" ==
-- Err ["expected 'a'"]
anyChar : Parser s Char

Parse any character.

parse anyChar "a" ==
-- Ok 'a'


parse anyChar "" ==
-- Err ["expected any character"]
oneOf : List Char -> Parser s Char

Parse a character from the given list.

parse (oneOf ['a', 'b']) "a" ==
-- Ok 'a'


parse (oneOf ['a', 'b']) "c" ==
-- Err ["expected one of ['a','b']"]
noneOf : List Char -> Parser s Char

Parse a character that is not in the given list.

parse (noneOf ['a', 'b']) "c" ==
-- Ok 'c'


parse (noneOf ['a', 'b']) "a" ==
-- Err ["expected none of ['a','b']"]
space : Parser s Char

Parse a space character.

tab : Parser s Char

Parse a \t character.

newline : Parser s Char

Parse a \n character.

crlf : Parser s Char

Parse a \r\n sequence, returning a \n character.

eol : Parser s Char

Parse an end of line character or sequence, returning a \n character.

lower : Parser s Char

Parse any lowercase character.

upper : Parser s Char

Parse any uppercase character.

digit : Parser s Char

Parse any base 10 digit.

octDigit : Parser s Char

Parse any base 8 digit.

hexDigit : Parser s Char

Parse any base 16 digit.