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

Contents

Synopsis

# functions

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
```

# raw functions

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

convert bytestring into unsigned fractional using radix.

this function can parse

• fractional(0.1, 12224.3543)
• exponential (e1, E+2, e-123) (optional)
````>>> ````fractional10 "12.5" :: Maybe (Double, S.ByteString)
```Just (12.5,"")
`>>> ````fractional10 "124.1e12" :: Maybe (Double, L.ByteString)
```Just (1.241e14,"")
`>>> ````fractional10 "12.5e-3" :: Maybe (Double, S.ByteString)
```Just (1.25e-2,"")
`>>> ````fractional10 "3.11e+3" :: Maybe (Double, L.ByteString)
```Just (3110.0,"")
```

fractional' :: (Radix b, ReadFractional r, Source s) => proxy b -> s -> Maybe (r, s) Source

convert bytestring into unsigned fractional using radix.

this function can parse

• fractional(0.1, 12224.3543)
````>>> ````fractional' (Proxy :: Proxy 36) "12z" :: Maybe (Double, S.ByteString)
```Just (1403.0,"")
`>>> ````fractional' (Proxy :: Proxy 2) "1012" :: Maybe (Double, L.ByteString)
```Just (5.0,"2")
`>>> ````fractional' (Proxy :: Proxy 10) "a12" :: Maybe (Double, S.ByteString)
```Nothing
```