mysql-haskell-1.1.5: pure haskell MySQL driver
CopyrightBryan O'Sullivan 2007-2015 Winterland 2016
LicenseBSD3
Maintainerdrkoster@qq.com
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Binary.Parser.Numeric

Description

Simple, efficient combinator parsing for numeric values.

Synopsis

Documentation

hexadecimal :: Integral a => Get a Source #

Parse and decode an unsigned hexadecimal number. The hex digits 'a' through 'f' may be upper or lower case.

This parser does not accept a leading "0x" string.

decimal :: Integral a => Get a Source #

Parse and decode an unsigned decimal number.

signed :: Num a => Get a -> Get a Source #

Parse a number with an optional leading '+' or '-' sign character.

rational :: Fractional a => Get a Source #

Parse a rational number.

The syntax accepted by this parser is the same as for double.

Note: this parser is not safe for use with inputs from untrusted sources. An input with a suitably large exponent such as "1e1000000000" will cause a huge Integer to be allocated, resulting in what is effectively a denial-of-service attack.

In most cases, it is better to use double or scientific instead.

double :: Get Double Source #

Parse a rational number and round to Double.

This parser accepts an optional leading sign character, followed by at least one decimal digit. The syntax similar to that accepted by the read function, with the exception that a trailing '.' or 'e' not followed by a number is not consumed.

Examples with behaviour identical to read:

parseOnly double "3"     == Right ("",1,3.0)
parseOnly double "3.1"   == Right ("",3,3.1)
parseOnly double "3e4"   == Right ("",3,30000.0)
parseOnly double "3.1e4" == Right ("",5,31000.0)
parseOnly double ".3"    == Left (".3",0,"takeWhile1")
parseOnly double "e3"    == Left ("e3",0,"takeWhile1")

Examples of differences from read:

parseOnly double "3.foo" == Right (".foo",1,3.0)
parseOnly double "3e"    == Right ("e",1,3.0)

This function does not accept string representations of "NaN" or "Infinity".

scientific :: Get Scientific Source #

Parse a scientific number.

The syntax accepted by this parser is the same as for double.

scientifically :: (Scientific -> a) -> Get a Source #

Parse a scientific number and convert to result using a user supply function.

The syntax accepted by this parser is the same as for double.