binary 0.5.0.1 → 0.5.0.2
raw patch · 5 files changed
+17/−16 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Binary: instance (Binary a) => Binary (Maybe a)
- Data.Binary: instance (Binary a) => Binary [a]
- Data.Binary: instance (Binary e) => Binary (IntMap e)
- Data.Binary: instance (Binary e) => Binary (Seq e)
- Data.Binary: instance (Binary e) => Binary (Tree e)
+ Data.Binary: instance Binary a => Binary (Maybe a)
+ Data.Binary: instance Binary a => Binary [a]
+ Data.Binary: instance Binary e => Binary (IntMap e)
+ Data.Binary: instance Binary e => Binary (Seq e)
+ Data.Binary: instance Binary e => Binary (Tree e)
- Data.Binary: decode :: (Binary a) => ByteString -> a
+ Data.Binary: decode :: Binary a => ByteString -> a
- Data.Binary: decodeFile :: (Binary a) => FilePath -> IO a
+ Data.Binary: decodeFile :: Binary a => FilePath -> IO a
- Data.Binary: encode :: (Binary a) => a -> ByteString
+ Data.Binary: encode :: Binary a => a -> ByteString
- Data.Binary: encodeFile :: (Binary a) => FilePath -> a -> IO ()
+ Data.Binary: encodeFile :: Binary a => FilePath -> a -> IO ()
- Data.Binary: get :: (Binary t) => Get t
+ Data.Binary: get :: Binary t => Get t
- Data.Binary: put :: (Binary t) => t -> Put
+ Data.Binary: put :: Binary t => t -> Put
Files
- binary.cabal +1/−1
- src/Data/Binary/Get.hs +12/−11
- tests/Benchmark.hs +1/−1
- tests/Makefile +2/−2
- tests/MemBench.hs +1/−1
binary.cabal view
@@ -1,5 +1,5 @@ name: binary-version: 0.5.0.1+version: 0.5.0.2 license: BSD3 license-file: LICENSE author: Lennart Kolmodin <kolmodin@dtek.chalmers.se>
src/Data/Binary/Get.hs view
@@ -106,11 +106,11 @@ -- | The Get monad is just a State monad carrying around the input ByteString -- We treat it as a strict state monad. -newtype Get a = Get { unGet :: S -> (a, S) }+newtype Get a = Get { unGet :: S -> (# a, S #) } instance Functor Get where fmap f m = Get (\s -> case unGet m s of- (a, s') -> (f a, s'))+ (# a, s' #) -> (# f a, s' #)) {-# INLINE fmap #-} #ifdef APPLICATIVE_IN_BASE@@ -121,26 +121,27 @@ -- Definition directly from Control.Monad.State.Strict instance Monad Get where- return a = Get (\s -> (a, s))+ return a = Get $ \s -> (# a, s #) {-# INLINE return #-} - m >>= k = Get (\s -> let (a, s') = unGet m s- in unGet (k a) s')+ m >>= k = Get $ \s -> case unGet m s of+ (# a, s' #) -> unGet (k a) s' {-# INLINE (>>=) #-} fail = failDesc instance MonadFix Get where- mfix f = Get (\s -> let (a,s') = unGet (f a) s- in (a,s'))+ mfix f = Get $ \s -> let (a,s') = case unGet (f a) s of+ (# a', s'' #) -> (a',s'')+ in (# a,s' #) ------------------------------------------------------------------------ get :: Get S-get = Get (\s -> (s, s))+get = Get $ \s -> (# s, s #) put :: S -> Get ()-put s = Get (\_ -> ((), s))+put s = Get $ \_ -> (# (), s #) ------------------------------------------------------------------------ --@@ -177,7 +178,7 @@ -- | Run the Get monad applies a 'get'-based parser on the input ByteString runGet :: Get a -> L.ByteString -> a-runGet m str = case unGet m (initState str) of (a, _) -> a+runGet m str = case unGet m (initState str) of (# a, _ #) -> a -- | Run the Get monad applies a 'get'-based parser on the input -- ByteString. Additional to the result of get it returns the number of@@ -185,7 +186,7 @@ runGetState :: Get a -> L.ByteString -> Int64 -> (a, L.ByteString, Int64) runGetState m str off = case unGet m (mkState str off) of- (a, ~(S s ss newOff)) -> (a, s `join` ss, newOff)+ (# a, ~(S s ss newOff) #) -> (a, s `join` ss, newOff) ------------------------------------------------------------------------
tests/Benchmark.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS -fbang-patterns #-}+{-# LANGUAGE BangPatterns #-} module Main (main) where import qualified Data.ByteString.Lazy as L
tests/Makefile view
@@ -8,7 +8,7 @@ ./qc 500 +RTS -qw -N2 bench:: Benchmark.hs MemBench.hs CBenchmark.o- ghc --make -O2 Benchmark.hs -fasm CBenchmark.o -o bench -no-recomp+ ghc --make -O2 -fliberate-case-threshold=1000 -fasm Benchmark.hs CBenchmark.o -o bench -fforce-recomp ./bench 100 bench-nb::@@ -16,7 +16,7 @@ ./bench-nb CBenchmark.o: CBenchmark.c- gcc -O -c $< -o $@+ gcc -O3 -c $< -o $@ hugs: runhugs -98 QC.hs
tests/MemBench.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS_GHC -fffi -fbang-patterns #-}+{-# LANGUAGE ForeignFunctionInterface, BangPatterns #-} module MemBench (memBench) where import Foreign