From e60838e986c669b82c3d4c9770706d532563cab7 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 10 Apr 2014 08:02:48 +0300 Subject: [PATCH] Updated criterion patch --- patching/patches/criterion-0.8.0.1.patch | 55 -------- patching/patches/criterion-0.8.0.2.patch | 171 +++++++++++++++++++++++ 2 files changed, 171 insertions(+), 55 deletions(-) delete mode 100644 patching/patches/criterion-0.8.0.1.patch create mode 100644 patching/patches/criterion-0.8.0.2.patch diff --git a/patching/patches/criterion-0.8.0.1.patch b/patching/patches/criterion-0.8.0.1.patch deleted file mode 100644 index 381d368e..00000000 --- a/patching/patches/criterion-0.8.0.1.patch +++ /dev/null @@ -1,55 +0,0 @@ -diff -ru orig/Criterion/IO.hs new/Criterion/IO.hs ---- orig/Criterion/IO.hs 2014-02-21 06:51:14.286525542 +0200 -+++ new/Criterion/IO.hs 2014-02-21 06:51:14.000000000 +0200 -@@ -1,4 +1,5 @@ - {-# LANGUAGE OverloadedStrings #-} -+{-# LANGUAGE CPP #-} - -- | - -- Module : Criterion.IO - -- Copyright : (c) 2009, 2010 Bryan O'Sullivan -@@ -21,7 +22,11 @@ - - 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) -@@ -56,6 +61,7 @@ - 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 -@@ -64,3 +70,13 @@ - 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 -diff -ru orig/criterion.cabal new/criterion.cabal ---- orig/criterion.cabal 2014-02-21 06:51:14.314525543 +0200 -+++ new/criterion.cabal 2014-02-21 06:51:14.000000000 +0200 -@@ -58,7 +58,7 @@ - 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, diff --git a/patching/patches/criterion-0.8.0.2.patch b/patching/patches/criterion-0.8.0.2.patch new file mode 100644 index 00000000..36bd9881 --- /dev/null +++ b/patching/patches/criterion-0.8.0.2.patch @@ -0,0 +1,171 @@ +diff -ru orig/Criterion/Analysis/Types.hs new/Criterion/Analysis/Types.hs +--- orig/Criterion/Analysis/Types.hs 2014-04-10 08:02:35.383848688 +0300 ++++ new/Criterion/Analysis/Types.hs 2014-04-10 08:02:34.000000000 +0300 +@@ -19,10 +19,12 @@ + , SampleAnalysis(..) + ) where + ++import Control.Applicative ((<$>), (<*>)) + import Control.DeepSeq (NFData(rnf)) +-import Data.Binary (Binary) ++import Data.Binary (Binary, put, get) + import Data.Data (Data, Typeable) + import Data.Int (Int64) ++import Data.Word (Word8) + import Data.Monoid (Monoid(..)) + import GHC.Generics (Generic) + import qualified Statistics.Resampling.Bootstrap as B +@@ -42,7 +44,14 @@ + -- ^ More than 3 times the IQR above the third quartile. + } deriving (Eq, Read, Show, Typeable, Data, Generic) + +-instance Binary Outliers ++instance Binary Outliers where ++ put (Outliers a b c d e) = do ++ put a ++ put b ++ put c ++ put d ++ put e ++ get = Outliers <$> get <*> get <*> get <*> get <*> get + instance NFData Outliers + + -- | A description of the extent to which outliers in the sample data +@@ -54,7 +63,19 @@ + -- are useless). + deriving (Eq, Ord, Read, Show, Typeable, Data, Generic) + +-instance Binary OutlierEffect ++instance Binary OutlierEffect where ++ put Unaffected = put (0 :: Word8) ++ put Slight = put (1 :: Word8) ++ put Moderate = put (2 :: Word8) ++ put Severe = put (3 :: Word8) ++ get = do ++ w <- get ++ case w :: Word8 of ++ 0 -> return Unaffected ++ 1 -> return Slight ++ 2 -> return Moderate ++ 3 -> return Severe ++ _ -> error "Binary.get for OutlierEffect failed" + instance NFData OutlierEffect + + instance Monoid Outliers where +@@ -77,7 +98,9 @@ + -- ^ Quantitative description of effect (a fraction between 0 and 1). + } deriving (Eq, Read, Show, Typeable, Data, Generic) + +-instance Binary OutlierVariance ++instance Binary OutlierVariance where ++ put (OutlierVariance a b c) = put a >> put b >> put c ++ get = OutlierVariance <$> get <*> get <*> get + + instance NFData OutlierVariance where + rnf OutlierVariance{..} = rnf ovEffect `seq` rnf ovDesc `seq` rnf ovFraction +@@ -89,7 +112,9 @@ + , anOutlierVar :: OutlierVariance + } deriving (Eq, Read, Show, Typeable, Data, Generic) + +-instance Binary SampleAnalysis ++instance Binary SampleAnalysis where ++ put (SampleAnalysis a b c) = put a >> put b >> put c ++ get = SampleAnalysis <$> get <*> get <*> get + + instance NFData SampleAnalysis where + rnf SampleAnalysis{..} = +diff -ru orig/Criterion/IO.hs new/Criterion/IO.hs +--- orig/Criterion/IO.hs 2014-04-10 08:02:35.383848688 +0300 ++++ new/Criterion/IO.hs 2014-04-10 08:02:34.000000000 +0300 +@@ -1,3 +1,4 @@ ++{-# LANGUAGE CPP #-} + {-# LANGUAGE OverloadedStrings #-} + -- | + -- Module : Criterion.IO +@@ -21,7 +22,11 @@ + + 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.ByteString.Char8 () + import Data.Version (Version(..)) +@@ -58,6 +63,7 @@ + writeResults path rs = withFile path WriteMode (flip hPutResults rs) + + readAll :: Binary a => Handle -> IO [a] ++#if MIN_VERSION_binary(0,6,3) + readAll handle = do + let go bs + | L.null bs = return [] +@@ -65,3 +71,12 @@ + Left (_, _, err) -> fail err + Right (bs', _, a) -> (a:) `fmap` go bs' + go =<< L.hGetContents handle ++#else ++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 +diff -ru orig/Criterion/Types.hs new/Criterion/Types.hs +--- orig/Criterion/Types.hs 2014-04-10 08:02:35.383848688 +0300 ++++ new/Criterion/Types.hs 2014-04-10 08:02:34.000000000 +0300 +@@ -45,11 +45,13 @@ + , ResultTree(..) + ) where + ++import Control.Applicative ((<$>), (<*>)) + import Control.DeepSeq (NFData, rnf) + import Control.Exception (evaluate) + import Criterion.Analysis.Types (Outliers(..), SampleAnalysis(..)) +-import Data.Binary (Binary) ++import Data.Binary (Binary (get, put)) + import Data.Data (Data, Typeable) ++import Data.Word (Word8) + import GHC.Generics (Generic) + import Statistics.Types (Sample) + +@@ -161,11 +163,21 @@ + , outliers :: Outliers + } deriving (Eq, Read, Show, Typeable, Data, Generic) + +-instance Binary Result ++instance Binary Result where ++ put (Result a b c d) = put a >> put b >> put c >> put d ++ get = Result <$> get <*> get <*> get <*> get + + type ResultForest = [ResultTree] + data ResultTree = Single Result + | Compare !Int ResultForest + deriving (Eq, Read, Show, Typeable, Data, Generic) + +-instance Binary ResultTree ++instance Binary ResultTree where ++ put (Single x) = put (0 :: Word8) >> put x ++ put (Compare x y) = put (1 :: Word8) >> put x >> put y ++ get = do ++ w <- get ++ case w :: Word8 of ++ 0 -> Single <$> get ++ 1 -> Compare <$> get <*> get ++ _ -> error "Binary.get for ResultTree failed" +diff -ru orig/criterion.cabal new/criterion.cabal +--- orig/criterion.cabal 2014-04-10 08:02:35.387848687 +0300 ++++ new/criterion.cabal 2014-04-10 08:02:34.000000000 +0300 +@@ -58,7 +58,7 @@ + build-depends: + aeson >= 0.3.2.12, + base < 5, +- binary >= 0.6.3.0, ++ binary >= 0.5.1, + bytestring >= 0.9 && < 1.0, + containers, + deepseq >= 1.1.0.0,