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

Safe HaskellNone
LanguageHaskell2010

Data.ByteString.Read.Integral

Synopsis

Documentation

integral' :: (Radix b, Num n, Source s) => proxy b -> s -> Maybe (n, s) Source

convert bytestring into unsigned integral using radix

>>> integral' (Proxy :: Proxy 10) "12345" :: Maybe (Int, S.ByteString)
Just (12345,"")
>>> integral' (Proxy :: Proxy 2) "10112" :: Maybe (Int, L.ByteString)
Just (11,"2")
>>> integral' (Proxy :: Proxy 36) "Z" :: Maybe (Double, S.ByteString)
Just (35.0,"")

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