binary 0.8.0.0 → 0.8.0.1
raw patch · 6 files changed
+41/−12 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Binary: class Binary t where put = gput . from get = to `fmap` gget
+ Data.Binary: class Binary t
Files
- binary.cabal +6/−2
- changelog.md +5/−0
- src/Data/Binary/Builder/Base.hs +7/−8
- src/Data/Binary/Get/Internal.hs +7/−2
- src/Data/Binary/Internal.hs +15/−0
- tests/Action.hs +1/−0
binary.cabal view
@@ -1,5 +1,5 @@ name: binary-version: 0.8.0.0+version: 0.8.0.1 license: BSD3 license-file: LICENSE author: Lennart Kolmodin <kolmodin@gmail.com>@@ -41,7 +41,8 @@ Data.Binary.Builder.Internal other-modules: Data.Binary.Builder.Base,- Data.Binary.Class+ Data.Binary.Class,+ Data.Binary.Internal if impl(ghc >= 7.2.1) cpp-options: -DGENERICS@@ -51,6 +52,9 @@ build-depends: ghc-prim ghc-options: -O2 -Wall -fliberate-case-threshold=1000++ if impl(ghc >= 7.11)+ ghc-options: -Wcompat -Wnoncanonical-monad-instances -- Due to circular dependency, we cannot make any of the test-suites or -- benchmark depend on the binary library. Instead, for each test-suite and
changelog.md view
@@ -1,6 +1,11 @@ binary ====== +binary-0.8.0.1+--------------++- Address compiler warnings.+ binary-0.8.0.0 --------------
src/Data/Binary/Builder/Base.hs view
@@ -74,15 +74,9 @@ import System.IO.Unsafe as IO ( unsafePerformIO ) -#ifdef BYTESTRING_IN_BASE-import Data.ByteString.Base (inlinePerformIO)-import qualified Data.ByteString.Base as S-import qualified Data.ByteString.Lazy.Base as L-#else-import Data.ByteString.Internal (inlinePerformIO)+import Data.Binary.Internal ( accursedUnutterablePerformIO ) import qualified Data.ByteString.Internal as S import qualified Data.ByteString.Lazy.Internal as L-#endif #if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__) import GHC.Base (ord,Int(..),uncheckedShiftRL#)@@ -204,7 +198,12 @@ then k buf else let !b = Buffer p (o+u) 0 l !bs = S.PS p o u- in return $! L.Chunk bs (inlinePerformIO (k b))+ -- It should be safe to use accursedUnutterablePerformIO here.+ -- The place in the buffer where we write is determined by the 'b'+ -- value, and writes should be deterministic. The thunk should not+ -- be floated out and shared since the buffer references the+ -- incoming foreign ptr.+ in return $! L.Chunk bs (accursedUnutterablePerformIO (k b)) {-# INLINE [0] flush #-} ------------------------------------------------------------------------
src/Data/Binary/Get/Internal.hs view
@@ -44,12 +44,13 @@ import Foreign import qualified Data.ByteString as B-import qualified Data.ByteString.Internal as B import qualified Data.ByteString.Unsafe as B import Control.Applicative import Control.Monad +import Data.Binary.Internal ( accursedUnutterablePerformIO )+ #if __GLASGOW_HASKELL__ < 704 && !defined(__HADDOCK__) -- needed for (# unboxing #) with magic hash -- Do we still need these? Works without on modern GHCs.@@ -413,7 +414,11 @@ unsafeReadN !n f = C $ \inp ks -> do ks (B.unsafeDrop n inp) $! f inp -- strict return +-- | @readNWith n f@ where @f@ must be deterministic and not have side effects. readNWith :: Int -> (Ptr a -> IO a) -> Get a readNWith n f = do- readN n $ \s -> B.inlinePerformIO $ B.unsafeUseAsCString s (f . castPtr)+ -- It should be safe to use accursedUnutterablePerformIO here.+ -- The action must be deterministic and not have any external side effects.+ -- It depends on the value of the ByteString so the value dependencies look OK.+ readN n $ \s -> accursedUnutterablePerformIO $ B.unsafeUseAsCString s (f . castPtr) {-# INLINE readNWith #-}
+ src/Data/Binary/Internal.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE CPP #-}++module Data.Binary.Internal + ( accursedUnutterablePerformIO ) where++#if MIN_VERSION_bytestring(0,10,6)+import Data.ByteString.Internal( accursedUnutterablePerformIO )+#else+import Data.ByteString.Internal( inlinePerformIO )++{-# INLINE accursedUnutterablePerformIO #-}+-- | You must be truly desperate to come to me for help.+accursedUnutterablePerformIO :: IO a -> a+accursedUnutterablePerformIO = inlinePerformIO+#endif
tests/Action.hs view
@@ -38,6 +38,7 @@ deriving (Show, Eq) instance Arbitrary Action where+ arbitrary = fmap Actions (gen_actions False) shrink action = case action of Actions [a] -> [a]