bytestring-read-0.3.1: fast ByteString to number converting library

Synopsis

# Documentation

class Source a Source

Minimal complete definition

Instances

 Source ByteString Source ByteString

# fractional

class (Fractional a, Num (Fraction a), Ord (Fraction a)) => ReadFractional a Source

Minimal complete definition

fractional :: (ReadFractional r, Source s) => s -> Maybe (r, s) Source

convert bytestring into unsigned fractional using radix.

this function can parse

• oct/hexa-decimal (0o,0O,0x,0X) (optional)
• fractional(0.1, 12224.3543)
• exponential (e1, E+2, e-123) (10-radixed only, optional)
````>>> ````fractional "12.4" :: Maybe (Double, S.ByteString)
```Just (12.4,"")
`>>> ````fractional "1.23e12" :: Maybe (Double, L.ByteString)
```Just (1.23e12,"")
`>>> ````fractional "0o0.4" :: Maybe (Double, S.ByteString)
```Just (0.5,"")
`>>> ````fractional "0x3f.12" :: Maybe (Double, L.ByteString)
```Just (63.0703125,"")
```

double :: Source s => s -> Maybe (Double, s) Source

```double = fractional
```

# integral

integral :: (Num n, Source s) => s -> Maybe (n, s) Source

```integral = `integral'` (Proxy :: Proxy 10)
```

int :: Source s => s -> Maybe (Int, s) Source

```int = integral
```

# common

signed :: (Source s, Num r) => (s -> Maybe (r, s)) -> s -> Maybe (r, s) Source

convert unsigned parser to signed parser.

this function can parse

• sign (+, -) (optional)
````>>> ````signed double ("12.4" :: S.ByteString)
```Just (12.4,"")
`>>> ````signed double ("-3.21e3" :: L.ByteString)
```Just (-3210.0,"")
`>>> ````signed double ("+0x1f.4" :: S.ByteString)
```Just (31.25,"")
```