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
- alpha :: MonadCatch m => Parser m Char Char
- alphaNum :: MonadCatch m => Parser m Char Char
- ascii :: MonadCatch m => Parser m Char Char
- asciiLower :: MonadCatch m => Parser m Char Char
- asciiUpper :: MonadCatch m => Parser m Char Char
- char :: MonadCatch m => Char -> Parser m Char Char
- decimal :: (MonadCatch m, Integral a) => Parser m Char a
- digit :: MonadCatch m => Parser m Char Char
- double :: Parser m Char Double
- hexadecimal :: (MonadCatch m, Integral a, Bits a) => Parser m Char a
- hexDigit :: MonadCatch m => Parser m Char Char
- latin1 :: MonadCatch m => Parser m Char Char
- letter :: MonadCatch m => Parser m Char Char
- lower :: MonadCatch m => Parser m Char Char
- mark :: MonadCatch m => Parser m Char Char
- number :: MonadCatch m => Parser m Char Char
- octDigit :: MonadCatch m => Parser m Char Char
- print :: MonadCatch m => Parser m Char Char
- punctuation :: MonadCatch m => Parser m Char Char
- separator :: MonadCatch m => Parser m Char Char
- signed :: (Num a, MonadCatch m) => Parser m Char a -> Parser m Char a
- space :: MonadCatch m => Parser m Char Char
- symbol :: MonadCatch m => Parser m Char Char
- upper :: MonadCatch m => Parser m Char Char
Documentation
asciiLower :: MonadCatch m => Parser m Char Char Source #
asciiUpper :: MonadCatch m => Parser m Char Char Source #
decimal :: (MonadCatch m, Integral a) => Parser m Char a Source #
Parse and decode an unsigned integral decimal number.
double :: Parser m Char 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
hexadecimal :: (MonadCatch m, Integral a, Bits a) => Parser m Char a Source #
Parse and decode an unsigned integral hexadecimal number. The hex digits
'a'
through 'f'
may be upper or lower case.
Note: This parser does not accept a leading "0x"
string.
punctuation :: MonadCatch m => Parser m Char Char Source #