packages feed

bytestring-show 0.2.1 → 0.3.1

raw patch · 4 files changed

+54/−3 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Show.ByteString: instance Show Int64
+ Text.Show.ByteString: instance Show Word64

Files

Tests/Properties.hs view
@@ -15,20 +15,30 @@ test_matchesShow :: (Show a, S.Show a, Arbitrary a) => a -> Bool test_matchesShow a = show a == L.unpack (S.show a) +instance Arbitrary Int64 where+    arbitrary = fmap fromInteger arbitrary+    coarbitrary _ = id++instance Arbitrary Word64 where+    arbitrary = fmap (fromInteger . abs) arbitrary+    coarbitrary _ = id+ test_all :: IO () test_all = do quickCheck (test_matchesShow :: Int -> Bool) --              quickCheck (test_matchesShow :: Int8 -> Bool) --              quickCheck (test_matchesShow :: Int16 -> Bool) --              quickCheck (test_matchesShow :: Int32 -> Bool)+              quickCheck (test_matchesShow :: Int64 -> Bool) --              quickCheck (test_matchesShow :: Word -> Bool) --              quickCheck (test_matchesShow :: Word8 -> Bool) --              quickCheck (test_matchesShow :: Word16 -> Bool) --              quickCheck (test_matchesShow :: Word32 -> Bool)+              quickCheck (test_matchesShow :: Word64 -> Bool)               quickCheck (test_matchesShow :: () -> Bool)               quickCheck (test_matchesShow :: Integer -> Bool)               quickCheck (test_matchesShow :: Float -> Bool)               quickCheck (test_matchesShow :: Double -> Bool)-              quickCheck (test_matchesShow :: Rational -> Bool)+--              quickCheck (test_matchesShow :: Rational -> Bool)               quickCheck (test_matchesShow :: (Int,Int,Int) -> Bool)               quickCheck (test_matchesShow :: (Int,Int,Int,Int) -> Bool)               quickCheck (test_matchesShow :: [Int] -> Bool)
Text/Show/ByteString.hs view
@@ -161,6 +161,11 @@    showpPrec k i = showpParen (i < 0 && k > 0) $ showpInt32 i +instance Show Int64 where+  showp = showpInt64++  showpPrec k i = showpParen (i < 0 && k > 0) $ showpInt64 i+ instance Show Word where   showp = showpWord @@ -172,6 +177,9 @@  instance Show Word32 where   showp = showpWord32++instance Show Word64 where+  showp = showpWord64  instance Show Integer where   showp = showpInteger
Text/Show/ByteString/Int.hs view
@@ -1,3 +1,4 @@+{-# OPTIONS_GHC -funbox-strict-fields -cpp #-} {-# LANGUAGE MagicHash #-}  -- ---------------------------------------------------------------------------@@ -12,6 +13,8 @@ -- -- The code in this module is based on the printing in the GHC modules. +#include "MachDeps.h"+ module Text.Show.ByteString.Int where  import GHC.Base@@ -49,6 +52,22 @@ showpInt32 :: Int32 -> Put showpInt32 (I32# i#) = putI i# +showpInt64 :: Int64 -> Put+#if WORD_SIZE_IN_BITS >= 64+showpInt64 (I64# i#) = putI i#+#else /* WORD_SIZE_IN_BITS < 64 */+showpInt64 = putI64++-- Unboxed 64-bit-specific operations aren't exported++putI64 :: Int64 -> Put+putI64 i | i == minBound = putWord8 45 +                           >> putW64 (fromIntegral $ negate (i `quot` 10)) +                           >> putW64 (fromIntegral $ negate (i `rem` 10))+         | i < 0         = putWord8 45 >> putW64 (fromIntegral $ negate i)+         | otherwise     = putW64 (fromIntegral i)+#endif+ showpWord :: Word -> Put showpWord (W# w#) = putW w# @@ -60,3 +79,17 @@  showpWord32 :: Word32 -> Put showpWord32 (W32# w#) = putW w#++showpWord64 :: Word64 -> Put+#if WORD_SIZE_IN_BITS >= 64+showpWord64 (W64# w#) = putW w#+#else /* WORD_SIZE_IN_BITS < 64 */+showpWord64 = putW64++putW64 :: Word64 -> Put+putW64 w | w < 10    = unsafePutDigit64 w+         | otherwise = putW64 (w `quot` 10) +                       >> unsafePutDigit64 (w `rem` 10)+    where unsafePutDigit64 w = unsafePutDigit# (case fromIntegral w of (W# w#) -> w#)++#endif
bytestring-show.cabal view
@@ -1,5 +1,5 @@ name:              bytestring-show-version:           0.2.1+version:           0.3.1 license:           BSD3 license-file:      LICENSE author:            Dan Doel@@ -9,7 +9,7 @@ synopsis:          Efficient conversion of values into readable byte strings. description:       Efficient conversion of values into readable byte strings. build-type:        Simple-cabal-version:     >= 1.2+cabal-version:     >= 1.2.3  library     build-depends: base, binary, bytestring >= 0.9, array, containers