HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulestreamly-core-0.2.2Haskell2010

Streamly.Unicode.Parser

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.

  • 29 values

Setup

0 declarations

To execute the code examples provided in this module in ghci, please run the following commands first.

Example3 expressions
:mimport qualified Streamly.Data.Stream as Streamimport qualified Streamly.Unicode.Parser as Unicode

For APIs that have not been released yet.

Example1 expression
import qualified Streamly.Internal.Unicode.Parser as Unicode (number, mkDouble)

Single Chars

21 declarations

Char Sequences

4 declarations

Digit Sequences (Numbers)

3 declarations
valuehexadecimal :: (Monad m, Integral a, Bits a) => Parser Char m a
#

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.

valuedouble :: Monad m => Parser Char m Double
#

Parse a decimal Double value. This parser accepts an optional sign (+ or -) followed by at least one decimal digit. Decimal digits are optionally followed by a decimal point and at least one decimal digit after the point. This parser accepts the maximal valid input as long as it gives a valid number. Specifcally a trailing decimal point is allowed but not consumed. This function does not accept "NaN" or "Infinity" string representations of double values.

Definition:

Example1 expression
double = uncurry Unicode.mkDouble <$> Unicode.number

Examples:

Example1 expression
p = Stream.parse Unicode.double . Stream.fromList
Example1 expression
p "-1.23e-123"Right (-1.23e-123)

Trailing input examples:

Example1 expression
p "1."Right 1.0
Example1 expression
p "1.2.3"Right 1.2
Example1 expression
p "1e"Right 1.0
Example1 expression
p "1e2.3"Right 100.0
Example1 expression
p "1+2"Right 1.0

Error cases:

Example1 expression
p ""Left (ParseError "number: expecting sign or decimal digit, got end of input")
Example1 expression
p ".1"Left (ParseError "number: expecting sign or decimal digit, got '.'")
Example1 expression
p "+"Left (ParseError "number: expecting decimal digit, got end of input")

Modifiers

1 declaration