on 1241af1 help sign in
stackage/patching/patches/statistics-0.10.5.2.patch
707 lines 27 kB history raw
1diff -ru orig/Statistics/Distribution/Beta.hs new/Statistics/Distribution/Beta.hs
2--- orig/Statistics/Distribution/Beta.hs 2014-02-19 18:51:48.636768606 +0200
3+++ new/Statistics/Distribution/Beta.hs 2014-02-19 18:51:48.000000000 +0200
4@@ -1,4 +1,4 @@
5-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
6+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
7 -----------------------------------------------------------------------------
8 -- |
9 -- Module : Statistics.Distribution.Beta
10@@ -27,6 +27,10 @@
11 incompleteBeta, invIncompleteBeta, logBeta, digamma)
12 import Numeric.MathFunctions.Constants (m_NaN)
13 import qualified Statistics.Distribution as D
14+#if !MIN_VERSION_binary(0, 6, 0)
15+import Data.Binary (put, get)
16+import Control.Applicative ((<$>), (<*>))
17+#endif
19 -- | The beta distribution
20 data BetaDistribution = BD
21@@ -36,7 +40,11 @@
22 -- ^ Beta shape parameter
23 } deriving (Eq, Read, Show, Typeable, Data, Generic)
25-instance Binary BetaDistribution
26+instance Binary BetaDistribution where
27+#if !MIN_VERSION_binary(0, 6, 0)
28+ put (BD x y) = put x >> put y
29+ get = BD <$> get <*> get
30+#endif
32 -- | Create beta distribution. Both shape parameters must be positive.
33 betaDistr :: Double -- ^ Shape parameter alpha
34diff -ru orig/Statistics/Distribution/Binomial.hs new/Statistics/Distribution/Binomial.hs
35--- orig/Statistics/Distribution/Binomial.hs 2014-02-19 18:51:48.636768606 +0200
36+++ new/Statistics/Distribution/Binomial.hs 2014-02-19 18:51:48.000000000 +0200
37@@ -1,4 +1,4 @@
38-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
39+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
40 -- |
41 -- Module : Statistics.Distribution.Binomial
42 -- Copyright : (c) 2009 Bryan O'Sullivan
43@@ -30,6 +30,10 @@
44 import qualified Statistics.Distribution.Poisson.Internal as I
45 import Numeric.SpecFunctions (choose,incompleteBeta)
46 import Numeric.MathFunctions.Constants (m_epsilon)
47+#if !MIN_VERSION_binary(0, 6, 0)
48+import Data.Binary (put, get)
49+import Control.Applicative ((<$>), (<*>))
50+#endif
53 -- | The binomial distribution.
54@@ -40,7 +44,11 @@
55 -- ^ Probability.
56 } deriving (Eq, Read, Show, Typeable, Data, Generic)
58-instance Binary BinomialDistribution
59+instance Binary BinomialDistribution where
60+#if !MIN_VERSION_binary(0, 6, 0)
61+ put (BD x y) = put x >> put y
62+ get = BD <$> get <*> get
63+#endif
65 instance D.Distribution BinomialDistribution where
66 cumulative = cumulative
67diff -ru orig/Statistics/Distribution/CauchyLorentz.hs new/Statistics/Distribution/CauchyLorentz.hs
68--- orig/Statistics/Distribution/CauchyLorentz.hs 2014-02-19 18:51:48.636768606 +0200
69+++ new/Statistics/Distribution/CauchyLorentz.hs 2014-02-19 18:51:48.000000000 +0200
70@@ -1,4 +1,4 @@
71-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
72+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
73 -- |
74 -- Module : Statistics.Distribution.CauchyLorentz
75 -- Copyright : (c) 2011 Aleksey Khudyakov
76@@ -25,6 +25,10 @@
77 import Data.Data (Data, Typeable)
78 import GHC.Generics (Generic)
79 import qualified Statistics.Distribution as D
80+#if !MIN_VERSION_binary(0, 6, 0)
81+import Data.Binary (put, get)
82+import Control.Applicative ((<$>), (<*>))
83+#endif
85 -- | Cauchy-Lorentz distribution.
86 data CauchyDistribution = CD {
87@@ -39,7 +43,11 @@
88 }
89 deriving (Eq, Show, Read, Typeable, Data, Generic)
91-instance Binary CauchyDistribution
92+instance Binary CauchyDistribution where
93+#if !MIN_VERSION_binary(0, 6, 0)
94+ put (CD x y) = put x >> put y
95+ get = CD <$> get <*> get
96+#endif
98 -- | Cauchy distribution
99 cauchyDistribution :: Double -- ^ Central point
100diff -ru orig/Statistics/Distribution/ChiSquared.hs new/Statistics/Distribution/ChiSquared.hs
101--- orig/Statistics/Distribution/ChiSquared.hs 2014-02-19 18:51:48.636768606 +0200
102+++ new/Statistics/Distribution/ChiSquared.hs 2014-02-19 18:51:48.000000000 +0200
103@@ -1,4 +1,4 @@
104-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
105+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
106 -- |
107 -- Module : Statistics.Distribution.ChiSquared
108 -- Copyright : (c) 2010 Alexey Khudyakov
109@@ -26,13 +26,20 @@
111 import qualified Statistics.Distribution as D
112 import qualified System.Random.MWC.Distributions as MWC
113+#if !MIN_VERSION_binary(0, 6, 0)
114+import Data.Binary (put, get)
115+#endif
118 -- | Chi-squared distribution
119 newtype ChiSquared = ChiSquared Int
120 deriving (Eq, Read, Show, Typeable, Data, Generic)
122-instance Binary ChiSquared
123+instance Binary ChiSquared where
124+#if !MIN_VERSION_binary(0, 6, 0)
125+ get = fmap ChiSquared get
126+ put (ChiSquared x) = put x
127+#endif
129 -- | Get number of degrees of freedom
130 chiSquaredNDF :: ChiSquared -> Int
131diff -ru orig/Statistics/Distribution/Exponential.hs new/Statistics/Distribution/Exponential.hs
132--- orig/Statistics/Distribution/Exponential.hs 2014-02-19 18:51:48.636768606 +0200
133+++ new/Statistics/Distribution/Exponential.hs 2014-02-19 18:51:48.000000000 +0200
134@@ -1,4 +1,4 @@
135-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
136+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
137 -- |
138 -- Module : Statistics.Distribution.Exponential
139 -- Copyright : (c) 2009 Bryan O'Sullivan
140@@ -31,13 +31,20 @@
141 import qualified Statistics.Sample as S
142 import qualified System.Random.MWC.Distributions as MWC
143 import Statistics.Types (Sample)
144+#if !MIN_VERSION_binary(0, 6, 0)
145+import Data.Binary (put, get)
146+#endif
149 newtype ExponentialDistribution = ED {
150 edLambda :: Double
151 } deriving (Eq, Read, Show, Typeable, Data, Generic)
153-instance Binary ExponentialDistribution
154+instance Binary ExponentialDistribution where
155+#if !MIN_VERSION_binary(0, 6, 0)
156+ put = put . edLambda
157+ get = fmap ED get
158+#endif
160 instance D.Distribution ExponentialDistribution where
161 cumulative = cumulative
162diff -ru orig/Statistics/Distribution/FDistribution.hs new/Statistics/Distribution/FDistribution.hs
163--- orig/Statistics/Distribution/FDistribution.hs 2014-02-19 18:51:48.636768606 +0200
164+++ new/Statistics/Distribution/FDistribution.hs 2014-02-19 18:51:48.000000000 +0200
165@@ -1,4 +1,4 @@
166-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
167+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
168 -- |
169 -- Module : Statistics.Distribution.FDistribution
170 -- Copyright : (c) 2011 Aleksey Khudyakov
171@@ -23,6 +23,10 @@
172 import qualified Statistics.Distribution as D
173 import Numeric.SpecFunctions (
174 logBeta, incompleteBeta, invIncompleteBeta, digamma)
175+#if !MIN_VERSION_binary(0, 6, 0)
176+import Data.Binary (put, get)
177+import Control.Applicative ((<$>), (<*>))
178+#endif
182@@ -33,7 +37,11 @@
183 }
184 deriving (Eq, Show, Read, Typeable, Data, Generic)
186-instance Binary FDistribution
187+instance Binary FDistribution where
188+#if !MIN_VERSION_binary(0, 6, 0)
189+ get = F <$> get <*> get <*> get
190+ put (F x y z) = put x >> put y >> put z
191+#endif
193 fDistribution :: Int -> Int -> FDistribution
194 fDistribution n m
195diff -ru orig/Statistics/Distribution/Gamma.hs new/Statistics/Distribution/Gamma.hs
196--- orig/Statistics/Distribution/Gamma.hs 2014-02-19 18:51:48.636768606 +0200
197+++ new/Statistics/Distribution/Gamma.hs 2014-02-19 18:51:48.000000000 +0200
198@@ -1,4 +1,4 @@
199-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
200+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
201 -- |
202 -- Module : Statistics.Distribution.Gamma
203 -- Copyright : (c) 2009, 2011 Bryan O'Sullivan
204@@ -34,6 +34,10 @@
205 import Statistics.Distribution.Poisson.Internal as Poisson
206 import qualified Statistics.Distribution as D
207 import qualified System.Random.MWC.Distributions as MWC
208+#if !MIN_VERSION_binary(0, 6, 0)
209+import Data.Binary (put, get)
210+import Control.Applicative ((<$>), (<*>))
211+#endif
213 -- | The gamma distribution.
214 data GammaDistribution = GD {
215@@ -41,7 +45,11 @@
216 , gdScale :: {-# UNPACK #-} !Double -- ^ Scale parameter, &#977;.
217 } deriving (Eq, Read, Show, Typeable, Data, Generic)
219-instance Binary GammaDistribution
220+instance Binary GammaDistribution where
221+#if !MIN_VERSION_binary(0, 6, 0)
222+ put (GD x y) = put x >> put y
223+ get = GD <$> get <*> get
224+#endif
226 -- | Create gamma distribution. Both shape and scale parameters must
227 -- be positive.
228diff -ru orig/Statistics/Distribution/Geometric.hs new/Statistics/Distribution/Geometric.hs
229--- orig/Statistics/Distribution/Geometric.hs 2014-02-19 18:51:48.636768606 +0200
230+++ new/Statistics/Distribution/Geometric.hs 2014-02-19 18:51:48.000000000 +0200
231@@ -1,4 +1,4 @@
232-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
233+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
234 -- |
235 -- Module : Statistics.Distribution.Geometric
236 -- Copyright : (c) 2009 Bryan O'Sullivan
237@@ -37,6 +37,10 @@
238 import Numeric.MathFunctions.Constants(m_pos_inf,m_neg_inf)
239 import qualified Statistics.Distribution as D
240 import qualified System.Random.MWC.Distributions as MWC
241+#if !MIN_VERSION_binary(0, 6, 0)
242+import Data.Binary (put, get)
243+import Control.Applicative ((<$>))
244+#endif
246 ----------------------------------------------------------------
247 -- Distribution over [1..]
248@@ -45,7 +49,11 @@
249 gdSuccess :: Double
250 } deriving (Eq, Read, Show, Typeable, Data, Generic)
252-instance Binary GeometricDistribution
253+instance Binary GeometricDistribution where
254+#if !MIN_VERSION_binary(0, 6, 0)
255+ get = GD <$> get
256+ put (GD x) = put x
257+#endif
259 instance D.Distribution GeometricDistribution where
260 cumulative = cumulative
261@@ -115,7 +123,11 @@
262 gdSuccess0 :: Double
263 } deriving (Eq, Read, Show, Typeable, Data, Generic)
265-instance Binary GeometricDistribution0
266+instance Binary GeometricDistribution0 where
267+#if !MIN_VERSION_binary(0, 6, 0)
268+ get = GD0 <$> get
269+ put (GD0 x) = put x
270+#endif
272 instance D.Distribution GeometricDistribution0 where
273 cumulative (GD0 s) x = cumulative (GD s) (x + 1)
274diff -ru orig/Statistics/Distribution/Hypergeometric.hs new/Statistics/Distribution/Hypergeometric.hs
275--- orig/Statistics/Distribution/Hypergeometric.hs 2014-02-19 18:51:48.636768606 +0200
276+++ new/Statistics/Distribution/Hypergeometric.hs 2014-02-19 18:51:48.000000000 +0200
277@@ -1,4 +1,4 @@
278-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
279+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
280 -- |
281 -- Module : Statistics.Distribution.Hypergeometric
282 -- Copyright : (c) 2009 Bryan O'Sullivan
283@@ -33,6 +33,10 @@
284 import Numeric.MathFunctions.Constants (m_epsilon)
285 import Numeric.SpecFunctions (choose)
286 import qualified Statistics.Distribution as D
287+#if !MIN_VERSION_binary(0, 6, 0)
288+import Data.Binary (put, get)
289+import Control.Applicative ((<$>), (<*>))
290+#endif
292 data HypergeometricDistribution = HD {
293 hdM :: {-# UNPACK #-} !Int
294@@ -40,7 +44,11 @@
295 , hdK :: {-# UNPACK #-} !Int
296 } deriving (Eq, Read, Show, Typeable, Data, Generic)
298-instance Binary HypergeometricDistribution
299+instance Binary HypergeometricDistribution where
300+#if !MIN_VERSION_binary(0, 6, 0)
301+ get = HD <$> get <*> get <*> get
302+ put (HD x y z) = put x >> put y >> put z
303+#endif
305 instance D.Distribution HypergeometricDistribution where
306 cumulative = cumulative
307diff -ru orig/Statistics/Distribution/Normal.hs new/Statistics/Distribution/Normal.hs
308--- orig/Statistics/Distribution/Normal.hs 2014-02-19 18:51:48.636768606 +0200
309+++ new/Statistics/Distribution/Normal.hs 2014-02-19 18:51:48.000000000 +0200
310@@ -1,4 +1,4 @@
311-{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric #-}
312+{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric, CPP #-}
313 -- |
314 -- Module : Statistics.Distribution.Normal
315 -- Copyright : (c) 2009 Bryan O'Sullivan
316@@ -28,6 +28,10 @@
317 import qualified Statistics.Distribution as D
318 import qualified Statistics.Sample as S
319 import qualified System.Random.MWC.Distributions as MWC
320+#if !MIN_VERSION_binary(0, 6, 0)
321+import Data.Binary (put, get)
322+import Control.Applicative ((<$>), (<*>))
323+#endif
327@@ -39,7 +43,9 @@
328 , ndCdfDenom :: {-# UNPACK #-} !Double
329 } deriving (Eq, Read, Show, Typeable, Data, Generic)
331-instance Binary NormalDistribution
332+instance Binary NormalDistribution where
333+ put (ND w x y z) = put w >> put x >> put y >> put z
334+ get = ND <$> get <*> get <*> get <*> get
336 instance D.Distribution NormalDistribution where
337 cumulative = cumulative
338diff -ru orig/Statistics/Distribution/Poisson/Internal.hs new/Statistics/Distribution/Poisson/Internal.hs
339--- orig/Statistics/Distribution/Poisson/Internal.hs 2014-02-19 18:51:48.636768606 +0200
340+++ new/Statistics/Distribution/Poisson/Internal.hs 2014-02-19 18:51:48.000000000 +0200
341@@ -36,8 +36,8 @@
342 -- | Compute entropy using Theorem 1 from "Sharp Bounds on the Entropy
343 -- of the Poisson Law". This function is unused because 'directEntorpy'
344 -- is just as accurate and is faster by about a factor of 4.
345-alyThm1 :: Double -> Double
346-alyThm1 lambda =
347+_alyThm1 :: Double -> Double
348+_alyThm1 lambda =
349 sum (takeWhile (\x -> abs x >= m_epsilon * lll) alySeries) + lll
350 where lll = lambda * (1 - log lambda)
351 alySeries =
352@@ -175,4 +175,4 @@
353 | lambda <= 18 = alyThm2 lambda upperCoefficients6 lowerCoefficients6
354 | lambda <= 24 = alyThm2 lambda upperCoefficients8 lowerCoefficients8
355 | lambda <= 30 = alyThm2 lambda upperCoefficients10 lowerCoefficients10
356- | otherwise = alyThm2 lambda upperCoefficients12 lowerCoefficients12
357\ No newline at end of file
358+ | otherwise = alyThm2 lambda upperCoefficients12 lowerCoefficients12
359diff -ru orig/Statistics/Distribution/Poisson.hs new/Statistics/Distribution/Poisson.hs
360--- orig/Statistics/Distribution/Poisson.hs 2014-02-19 18:51:48.636768606 +0200
361+++ new/Statistics/Distribution/Poisson.hs 2014-02-19 18:51:48.000000000 +0200
362@@ -1,4 +1,4 @@
363-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
364+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
365 -- |
366 -- Module : Statistics.Distribution.Poisson
367 -- Copyright : (c) 2009, 2011 Bryan O'Sullivan
368@@ -31,13 +31,20 @@
369 import qualified Statistics.Distribution.Poisson.Internal as I
370 import Numeric.SpecFunctions (incompleteGamma,logFactorial)
371 import Numeric.MathFunctions.Constants (m_neg_inf)
372+#if !MIN_VERSION_binary(0, 6, 0)
373+import Data.Binary (put, get)
374+#endif
377 newtype PoissonDistribution = PD {
378 poissonLambda :: Double
379 } deriving (Eq, Read, Show, Typeable, Data, Generic)
381-instance Binary PoissonDistribution
382+instance Binary PoissonDistribution where
383+#if !MIN_VERSION_binary(0, 6, 0)
384+ get = fmap PD get
385+ put = put . poissonLambda
386+#endif
388 instance D.Distribution PoissonDistribution where
389 cumulative (PD lambda) x
390@@ -78,8 +85,9 @@
391 poisson :: Double -> PoissonDistribution
392 poisson l
393 | l >= 0 = PD l
394- | otherwise = error $ "Statistics.Distribution.Poisson.poisson:\
395- \ lambda must be non-negative. Got " ++ show l
396+ | otherwise = error $
397+ "Statistics.Distribution.Poisson.poisson: lambda must be non-negative. Got "
398+ ++ show l
399 {-# INLINE poisson #-}
401 -- $references
402diff -ru orig/Statistics/Distribution/StudentT.hs new/Statistics/Distribution/StudentT.hs
403--- orig/Statistics/Distribution/StudentT.hs 2014-02-19 18:51:48.636768606 +0200
404+++ new/Statistics/Distribution/StudentT.hs 2014-02-19 18:51:48.000000000 +0200
405@@ -1,4 +1,4 @@
406-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
407+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
408 -- |
409 -- Module : Statistics.Distribution.StudentT
410 -- Copyright : (c) 2011 Aleksey Khudyakov
411@@ -23,12 +23,19 @@
412 import Statistics.Distribution.Transform (LinearTransform (..))
413 import Numeric.SpecFunctions (
414 logBeta, incompleteBeta, invIncompleteBeta, digamma)
415+#if !MIN_VERSION_binary(0, 6, 0)
416+import Data.Binary (put, get)
417+#endif
419 -- | Student-T distribution
420 newtype StudentT = StudentT { studentTndf :: Double }
421 deriving (Eq, Show, Read, Typeable, Data, Generic)
423-instance Binary StudentT
424+instance Binary StudentT where
425+#if !MIN_VERSION_binary(0, 6, 0)
426+ put = put . studentTndf
427+ get = fmap StudentT get
428+#endif
430 -- | Create Student-T distribution. Number of parameters must be positive.
431 studentT :: Double -> StudentT
432diff -ru orig/Statistics/Distribution/Transform.hs new/Statistics/Distribution/Transform.hs
433--- orig/Statistics/Distribution/Transform.hs 2014-02-19 18:51:48.636768606 +0200
434+++ new/Statistics/Distribution/Transform.hs 2014-02-19 18:51:48.000000000 +0200
435@@ -1,5 +1,5 @@
436 {-# LANGUAGE DeriveDataTypeable, DeriveGeneric, FlexibleContexts,
437- FlexibleInstances, UndecidableInstances #-}
438+ FlexibleInstances, UndecidableInstances, CPP #-}
439 -- |
440 -- Module : Statistics.Distribution.Transform
441 -- Copyright : (c) 2013 John McDonnell;
442@@ -21,6 +21,10 @@
443 import GHC.Generics (Generic)
444 import Data.Functor ((<$>))
445 import qualified Statistics.Distribution as D
446+#if !MIN_VERSION_binary(0, 6, 0)
447+import Data.Binary (put, get)
448+import Control.Applicative ((<*>))
449+#endif
451 -- | Linear transformation applied to distribution.
452 --
453@@ -35,7 +39,11 @@
454 -- ^ Distribution being transformed.
455 } deriving (Eq, Show, Read, Typeable, Data, Generic)
457-instance (Binary d) => Binary (LinearTransform d)
458+instance (Binary d) => Binary (LinearTransform d) where
459+#if !MIN_VERSION_binary(0, 6, 0)
460+ get = LinearTransform <$> get <*> get <*> get
461+ put (LinearTransform x y z) = put x >> put y >> put z
462+#endif
464 -- | Apply linear transformation to distribution.
465 scaleAround :: Double -- ^ Fixed point
466diff -ru orig/Statistics/Distribution/Uniform.hs new/Statistics/Distribution/Uniform.hs
467--- orig/Statistics/Distribution/Uniform.hs 2014-02-19 18:51:48.636768606 +0200
468+++ new/Statistics/Distribution/Uniform.hs 2014-02-19 18:51:48.000000000 +0200
469@@ -1,4 +1,4 @@
470-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
471+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
472 -- |
473 -- Module : Statistics.Distribution.Uniform
474 -- Copyright : (c) 2011 Aleksey Khudyakov
475@@ -24,6 +24,10 @@
476 import GHC.Generics (Generic)
477 import qualified Statistics.Distribution as D
478 import qualified System.Random.MWC as MWC
479+#if !MIN_VERSION_binary(0, 6, 0)
480+import Data.Binary (put, get)
481+import Control.Applicative ((<$>), (<*>))
482+#endif
485 -- | Uniform distribution from A to B
486@@ -32,7 +36,11 @@
487 , uniformB :: {-# UNPACK #-} !Double -- ^ Upper boundary of distribution
488 } deriving (Eq, Read, Show, Typeable, Data, Generic)
490-instance Binary UniformDistribution
491+instance Binary UniformDistribution where
492+#if !MIN_VERSION_binary(0, 6, 0)
493+ put (UniformDistribution x y) = put x >> put y
494+ get = UniformDistribution <$> get <*> get
495+#endif
497 -- | Create uniform distribution.
498 uniformDistr :: Double -> Double -> UniformDistribution
499diff -ru orig/Statistics/Math/RootFinding.hs new/Statistics/Math/RootFinding.hs
500--- orig/Statistics/Math/RootFinding.hs 2014-02-19 18:51:48.636768606 +0200
501+++ new/Statistics/Math/RootFinding.hs 2014-02-19 18:51:48.000000000 +0200
502@@ -1,4 +1,4 @@
503-{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric #-}
504+{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric, CPP #-}
506 -- |
507 -- Module : Statistics.Math.RootFinding
508@@ -27,6 +27,11 @@
509 import Control.Monad (MonadPlus(..), ap)
510 import Data.Data (Data, Typeable)
511 import GHC.Generics (Generic)
512+#if !MIN_VERSION_binary(0, 6, 0)
513+import Data.Binary (put, get)
514+import Data.Binary.Put (putWord8)
515+import Data.Binary.Get (getWord8)
516+#endif
519 -- | The result of searching for a root of a mathematical function.
520@@ -40,7 +45,20 @@
521 -- ^ A root was successfully found.
522 deriving (Eq, Read, Show, Typeable, Data, Generic)
524-instance (Binary a) => Binary (Root a)
525+instance (Binary a) => Binary (Root a) where
526+#if !MIN_VERSION_binary(0, 6, 0)
527+ put NotBracketed = putWord8 0
528+ put SearchFailed = putWord8 1
529+ put (Root a) = putWord8 2 >> put a
531+ get = do
532+ i <- getWord8
533+ case i of
534+ 0 -> return NotBracketed
535+ 1 -> return SearchFailed
536+ 2 -> fmap Root get
537+ _ -> fail $ "Root.get: Invalid value: " ++ show i
538+#endif
540 instance Functor Root where
541 fmap _ NotBracketed = NotBracketed
542diff -ru orig/Statistics/Resampling/Bootstrap.hs new/Statistics/Resampling/Bootstrap.hs
543--- orig/Statistics/Resampling/Bootstrap.hs 2014-02-19 18:51:48.636768606 +0200
544+++ new/Statistics/Resampling/Bootstrap.hs 2014-02-19 18:51:48.000000000 +0200
545@@ -1,5 +1,5 @@
546 {-# LANGUAGE DeriveDataTypeable, DeriveGeneric, OverloadedStrings,
547- RecordWildCards #-}
548+ RecordWildCards, CPP #-}
550 -- |
551 -- Module : Statistics.Resampling.Bootstrap
552@@ -35,6 +35,10 @@
553 import Statistics.Sample (mean)
554 import Statistics.Types (Estimator, Sample)
555 import qualified Data.Vector.Unboxed as U
556+#if !MIN_VERSION_binary(0, 6, 0)
557+import Data.Binary (put, get)
558+import Control.Applicative ((<$>), (<*>))
559+#endif
561 -- | A point and interval estimate computed via an 'Estimator'.
562 data Estimate = Estimate {
563@@ -50,7 +54,11 @@
564 -- ^ Confidence level of the confidence intervals.
565 } deriving (Eq, Read, Show, Typeable, Data, Generic)
567-instance Binary Estimate
568+instance Binary Estimate where
569+#if !MIN_VERSION_binary(0, 6, 0)
570+ put (Estimate w x y z) = put w >> put x >> put y >> put z
571+ get = Estimate <$> get <*> get <*> get <*> get
572+#endif
573 instance NFData Estimate
575 -- | Multiply the point, lower bound, and upper bound in an 'Estimate'
576diff -ru orig/Statistics/Resampling.hs new/Statistics/Resampling.hs
577--- orig/Statistics/Resampling.hs 2014-02-19 18:51:48.636768606 +0200
578+++ new/Statistics/Resampling.hs 2014-02-19 18:51:48.000000000 +0200
579@@ -1,4 +1,4 @@
580-{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric #-}
581+{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric, CPP #-}
583 -- |
584 -- Module : Statistics.Resampling
585@@ -42,7 +42,11 @@
586 fromResample :: U.Vector Double
587 } deriving (Eq, Read, Show, Typeable, Data, Generic)
589-instance Binary Resample
590+instance Binary Resample where
591+#if !MIN_VERSION_binary(0, 6, 0)
592+ put = put . fromResample
593+ get = fmap Resample get
594+#endif
596 -- | /O(e*r*s)/ Resample a data set repeatedly, with replacement,
597 -- computing each estimate over the resampled data.
598diff -ru orig/Statistics/Sample/KernelDensity/Simple.hs new/Statistics/Sample/KernelDensity/Simple.hs
599--- orig/Statistics/Sample/KernelDensity/Simple.hs 2014-02-19 18:51:48.640768606 +0200
600+++ new/Statistics/Sample/KernelDensity/Simple.hs 2014-02-19 18:51:48.000000000 +0200
601@@ -1,4 +1,4 @@
602-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, FlexibleContexts #-}
603+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, FlexibleContexts, CPP #-}
604 -- |
605 -- Module : Statistics.Sample.KernelDensity.Simple
606 -- Copyright : (c) 2009 Bryan O'Sullivan
607@@ -61,7 +61,11 @@
608 fromPoints :: U.Vector Double
609 } deriving (Eq, Read, Show, Typeable, Data, Generic)
611-instance Binary Points
612+instance Binary Points where
613+#if !MIN_VERSION_binary(0, 6, 0)
614+ get = fmap Points get
615+ put = put . fromPoints
616+#endif
618 -- | Bandwidth estimator for an Epanechnikov kernel.
619 epanechnikovBW :: Double -> Bandwidth
620diff -ru orig/Statistics/Sample/Powers.hs new/Statistics/Sample/Powers.hs
621--- orig/Statistics/Sample/Powers.hs 2014-02-19 18:51:48.636768606 +0200
622+++ new/Statistics/Sample/Powers.hs 2014-02-19 18:51:48.000000000 +0200
623@@ -1,5 +1,5 @@
624 {-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric,
625- FlexibleContexts #-}
626+ FlexibleContexts, CPP #-}
627 -- |
628 -- Module : Statistics.Sample.Powers
629 -- Copyright : (c) 2009, 2010 Bryan O'Sullivan
630@@ -65,7 +65,11 @@
631 newtype Powers = Powers (U.Vector Double)
632 deriving (Eq, Read, Show, Typeable, Data, Generic)
634-instance Binary Powers
635+instance Binary Powers where
636+#if !MIN_VERSION_binary(0, 6, 0)
637+ put (Powers v) = put v
638+ get = fmap Powers get
639+#endif
641 -- | O(/n/) Collect the /n/ simple powers of a sample.
642 --
643diff -ru orig/statistics.cabal new/statistics.cabal
644--- orig/statistics.cabal 2014-02-19 18:51:48.676768606 +0200
645+++ new/statistics.cabal 2014-02-19 18:51:48.000000000 +0200
646@@ -90,7 +90,7 @@
647 Statistics.Test.Internal
648 build-depends:
649 base < 5,
650- binary >= 0.6.3.0,
651+ binary >= 0.5.1.0,
652 deepseq >= 1.1.0.2,
653 erf,
654 monad-par >= 0.3.4,
655diff -ru orig/tests/Tests/Distribution.hs new/tests/Tests/Distribution.hs
656--- orig/tests/Tests/Distribution.hs 2014-02-19 18:51:48.676768606 +0200
657+++ new/tests/Tests/Distribution.hs 2014-02-19 18:51:48.000000000 +0200
658@@ -188,7 +188,7 @@
660 -- Quantile is inverse of CDF
661 quantileIsInvCDF :: (Param d, ContDistr d) => T d -> d -> Double -> Property
662-quantileIsInvCDF _ d (snd . properFraction -> p) =
663+quantileIsInvCDF _ d ((snd :: (Int, y) -> y) . properFraction -> p) =
664 p > 0 && p < 1 ==> ( printTestCase (printf "Quantile = %g" q )
665 $ printTestCase (printf "Probability = %g" p )
666 $ printTestCase (printf "Probability' = %g" p')
667@@ -203,8 +203,8 @@
668 quantileShouldFail :: (ContDistr d) => T d -> d -> Double -> Property
669 quantileShouldFail _ d p =
670 p < 0 || p > 1 ==> QC.monadicIO $ do r <- QC.run $ catch
671- (do { return $! quantile d p; return False })
672- (\(e :: SomeException) -> return True)
673+ (do { _ <- return $! quantile d p; return False })
674+ (\(_e :: SomeException) -> return True)
675 QC.assert r
678diff -ru orig/tests/Tests/Function.hs new/tests/Tests/Function.hs
679--- orig/tests/Tests/Function.hs 2014-02-19 18:51:48.676768606 +0200
680+++ new/tests/Tests/Function.hs 2014-02-19 18:51:48.000000000 +0200
681@@ -1,7 +1,6 @@
682 module Tests.Function ( tests ) where
684 import qualified Data.Vector.Unboxed as U
685-import Data.Vector.Unboxed ((!))
687 import Test.QuickCheck
688 import Test.Framework
689@@ -29,5 +28,5 @@
690 p_nextHighestPowerOfTwo
691 = all (\(good, is) -> all ((==good) . nextHighestPowerOfTwo) is) lists
692 where
693- pows = [1 .. 17]
694+ pows = [1 .. 17 :: Int]
695 lists = [ (2^m, [2^n+1 .. 2^m]) | (n,m) <- pows `zip` tail pows ]
696diff -ru orig/tests/Tests/Transform.hs new/tests/Tests/Transform.hs
697--- orig/tests/Tests/Transform.hs 2014-02-19 18:51:48.672768606 +0200
698+++ new/tests/Tests/Transform.hs 2014-02-19 18:51:48.000000000 +0200
699@@ -15,7 +15,7 @@
700 import Test.Framework (Test, testGroup)
701 import Test.Framework.Providers.QuickCheck2 (testProperty)
702 import Test.QuickCheck (Positive(..),Property,Arbitrary(..),Gen,choose,vectorOf,
703- printTestCase, quickCheck)
704+ printTestCase)
706 import Text.Printf