Copyright | (c) 2021 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
To parse a text input, use the decode routines from Streamly.Unicode.Stream module to convert an input byte stream to a Unicode Char stream and then use these parsers on the Char stream.
Synopsis
- char :: Monad m => Char -> Parser Char m Char
- charIgnoreCase :: Monad m => Char -> Parser Char m Char
- string :: Monad m => String -> Parser Char m String
- stringIgnoreCase :: Monad m => String -> Parser Char m String
- dropSpace :: Monad m => Parser Char m ()
- dropSpace1 :: Monad m => Parser Char m ()
- alpha :: Monad m => Parser Char m Char
- alphaNum :: Monad m => Parser Char m Char
- letter :: Monad m => Parser Char m Char
- ascii :: Monad m => Parser Char m Char
- asciiLower :: Monad m => Parser Char m Char
- asciiUpper :: Monad m => Parser Char m Char
- latin1 :: Monad m => Parser Char m Char
- lower :: Monad m => Parser Char m Char
- upper :: Monad m => Parser Char m Char
- mark :: Monad m => Parser Char m Char
- printable :: Monad m => Parser Char m Char
- punctuation :: Monad m => Parser Char m Char
- separator :: Monad m => Parser Char m Char
- space :: Monad m => Parser Char m Char
- symbol :: Monad m => Parser Char m Char
- digit :: Monad m => Parser Char m Char
- octDigit :: Monad m => Parser Char m Char
- hexDigit :: Monad m => Parser Char m Char
- numeric :: Monad m => Parser Char m Char
- signed :: (Num a, Monad m) => Parser Char m a -> Parser Char m a
- double :: Parser Char m Double
- decimal :: (Monad m, Integral a) => Parser Char m a
- hexadecimal :: (Monad m, Integral a, Bits a) => Parser Char m a
Generic
charIgnoreCase :: Monad m => Char -> Parser Char m Char Source #
Match a specific character ignoring case.
Sequences
string :: Monad m => String -> Parser Char m String Source #
Match the input with the supplied string and return it if successful.
stringIgnoreCase :: Monad m => String -> Parser Char m String Source #
Match the input with the supplied string and return it if successful.
Classes
asciiLower :: Monad m => Parser Char m Char Source #
Match any character that satisfies isAsciiLower
asciiUpper :: Monad m => Parser Char m Char Source #
Match any character that satisfies isAsciiUpper
punctuation :: Monad m => Parser Char m Char Source #
Match any character that satisfies isPunctuation
Numeric
signed :: (Num a, Monad m) => Parser Char m a -> Parser Char m a Source #
Allow an optional leading '+'
or '-'
sign character before any
parser.
double :: Parser Char m Double Source #
Parse a Double
.
This parser accepts an optional leading sign character, followed by
at most one decimal digit. The syntax is similar to that accepted by
the read
function, with the exception that a trailing '.'
is
consumed.
Examples
Examples with behaviour identical to read
, if you feed an empty
continuation to the first result:
IS.parse double (IS.fromList "3") == 3.0 IS.parse double (IS.fromList "3.1") == 3.1 IS.parse double (IS.fromList "3e4") == 30000.0 IS.parse double (IS.fromList "3.1e4") == 31000.0 IS.parse double (IS.fromList "3e") == 30
Examples with behaviour identical to read
:
IS.parse (IS.fromList ".3") == error "Parse failed" IS.parse (IS.fromList "e3") == error "Parse failed"
Example of difference from read
:
IS.parse double (IS.fromList "3.foo") == 3.0
This function does not accept string representations of "NaN" or "Infinity".
Unimplemented