bytestring-nums 0.3.5 → 0.3.6
raw patch · 4 files changed
+10/−5 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.ByteString.Nums.Careless.Float: lazy_float :: Fractional a => ByteString -> a
+ Data.ByteString.Nums.Careless.Float: lazy_float :: Fractional f => ByteString -> f
- Data.ByteString.Nums.Careless.Float: strict_float :: Fractional a => ByteString -> a
+ Data.ByteString.Nums.Careless.Float: strict_float :: Fractional f => ByteString -> f
- Data.ByteString.Nums.Careless.Hex: lazy_hex :: Num a => ByteString -> a
+ Data.ByteString.Nums.Careless.Hex: lazy_hex :: Num n => ByteString -> n
- Data.ByteString.Nums.Careless.Hex: strict_hex :: Num a => ByteString -> a
+ Data.ByteString.Nums.Careless.Hex: strict_hex :: Num n => ByteString -> n
- Data.ByteString.Nums.Careless.Int: lazy_signed :: Num a => ByteString -> a
+ Data.ByteString.Nums.Careless.Int: lazy_signed :: Num n => ByteString -> n
- Data.ByteString.Nums.Careless.Int: negative :: Num a => a -> Word8 -> a
+ Data.ByteString.Nums.Careless.Int: negative :: Num n => n -> Word8 -> n
- Data.ByteString.Nums.Careless.Int: positive :: Num a => a -> Word8 -> a
+ Data.ByteString.Nums.Careless.Int: positive :: Num n => n -> Word8 -> n
- Data.ByteString.Nums.Careless.Int: strict_signed :: Num a => ByteString -> a
+ Data.ByteString.Nums.Careless.Int: strict_signed :: Num n => ByteString -> n
Files
- Data/ByteString/Nums/Careless/Float.hs +3/−1
- Data/ByteString/Nums/Careless/Hex.hs +2/−2
- Data/ByteString/Nums/Careless/Int.hs +4/−1
- bytestring-nums.cabal +1/−1
Data/ByteString/Nums/Careless/Float.hs view
@@ -9,7 +9,6 @@ module Data.ByteString.Nums.Careless.Float where -import Data.Char import Prelude hiding (break, length, null, drop, tail, head) import Data.ByteString hiding (head, break, pack) import Data.ByteString.Char8 hiding (inits, elem, last, foldl')@@ -47,6 +46,7 @@ +strict_float :: (Fractional f) => ByteString -> f strict_float bytes | null bytes = 0 | head bytes == '-' = foldn 0 (tail integer) + nfrac@@ -66,6 +66,7 @@ | otherwise = foldp 0 fractional' * p +lazy_float :: (Fractional f) => Lazy.ByteString -> f lazy_float bytes | Lazy.null bytes = 0 | Lazy.head bytes == '-' = foldn 0 (Lazy.tail integer) + nfrac@@ -85,6 +86,7 @@ | otherwise = foldp 0 fractional' * p +point :: Char -> Bool point c = c == '.' || c == ','
Data/ByteString/Nums/Careless/Hex.hs view
@@ -12,9 +12,7 @@ import Prelude hiding (head, tail, drop) import Data.Word import Data.Int-import Data.Ratio import Data.ByteString hiding (head, pack)-import Data.ByteString.Char8 hiding (foldl') import Data.ByteString.Internal import qualified Data.ByteString.Lazy.Char8 as Lazy import qualified Data.ByteString.Lazy.Internal as Lazy@@ -100,8 +98,10 @@ between a z = byte >= c2w a && byte <= c2w z place_up b = (0x10 * acc) + fromIntegral b +strict_hex :: (Num n) => ByteString -> n strict_hex bytes = foldl' hexalize 0 bytes +lazy_hex :: (Num n) => Lazy.ByteString -> n lazy_hex bytes = Lazy.foldlChunks (foldl' hexalize) 0 bytes
Data/ByteString/Nums/Careless/Int.hs view
@@ -12,7 +12,6 @@ import Prelude hiding (head, tail, null) import Data.Word import Data.Int-import Data.Ratio import Data.ByteString hiding (head, pack) import Data.ByteString.Internal import Data.ByteString.Char8 hiding (foldl')@@ -93,6 +92,7 @@ lazy_unsigned :: (Num n) => Lazy.ByteString -> n lazy_unsigned = Lazy.foldlChunks (foldl' positive) 0 +lazy_signed :: (Num n) => Lazy.ByteString -> n lazy_signed bytes | Lazy.null bytes = 0 | Lazy.head bytes == '-' = fold negative 0 (Lazy.tail bytes)@@ -105,6 +105,7 @@ strict_unsigned :: (Num n) => ByteString -> n strict_unsigned = foldl' positive 0 +strict_signed :: (Num n) => ByteString -> n strict_signed bytes | null bytes = 0 | head bytes == '-' = foldl' negative 0 (tail bytes)@@ -112,8 +113,10 @@ | otherwise = foldl' positive 0 bytes +positive :: (Num n) => n -> Word8 -> n positive acc byte = (acc * 10) + fromIntegral (byte - c2w '0') +negative :: (Num n) => n -> Word8 -> n negative acc byte = (acc * 10) - fromIntegral (byte - c2w '0')
bytestring-nums.cabal view
@@ -1,5 +1,5 @@ name : bytestring-nums-version : 0.3.5+version : 0.3.6 category : Text license : BSD3 license-file : LICENSE