Commits

Michael Snoyman  committed 81dde39

binary 0.5 support

  • Participants
  • Parent commits 2622949

Comments (0)

Files changed (2)

File Criterion/IO.hs

 {-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE CPP #-}
 -- |
 -- Module      : Criterion.IO
 -- Copyright   : (c) 2009, 2010 Bryan O'Sullivan
 
 import Criterion.Types (ResultForest, ResultTree(..))
 import Data.Binary (Binary(..), encode)
+#if MIN_VERSION_binary(0, 6, 3)
 import Data.Binary.Get (runGetOrFail)
+#else
+import Data.Binary.Get (runGetState)
+#endif
 import Data.Binary.Put (putByteString, putWord16be, runPut)
 import Data.Version (Version(..))
 import Paths_criterion (version)
 writeResults :: FilePath -> ResultForest -> IO ()
 writeResults path rs = withFile path WriteMode (flip hPutResults rs)
 
+#if MIN_VERSION_binary(0, 6, 3)
 readAll :: Binary a => Handle -> IO [a]
 readAll handle = do
   let go bs
                          Left (_, _, err) -> fail err
                          Right (bs', _, a) -> (a:) `fmap` go bs'
   go =<< L.hGetContents handle
+#else
+readAll :: Binary a => Handle -> IO [a]
+readAll handle = do
+  let go i bs
+         | L.null bs = return []
+         | otherwise =
+            let (a, bs', i') = runGetState get bs i
+             in (a:) `fmap` go i' bs'
+  go 0 =<< L.hGetContents handle
+#endif

File criterion.cabal

   build-depends:
     aeson >= 0.3.2.12,
     base < 5,
-    binary >= 0.6.3.0,
+    binary >= 0.5.1.0,
     bytestring >= 0.9 && < 1.0,
     containers,
     deepseq >= 1.1.0.0,