on 869c80a help sign in
stackage/patching/patches/statistics-0.10.5.2.patch
705 lines 27 kB history raw
1diff -ru orig/Statistics/Distribution/Beta.hs new/Statistics/Distribution/Beta.hs
2--- orig/Statistics/Distribution/Beta.hs 2014-04-14 09:04:31.421509375 +0300
3+++ new/Statistics/Distribution/Beta.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
36+++ new/Statistics/Distribution/Binomial.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
69+++ new/Statistics/Distribution/CauchyLorentz.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
102+++ new/Statistics/Distribution/ChiSquared.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
133+++ new/Statistics/Distribution/Exponential.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
164+++ new/Statistics/Distribution/FDistribution.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
197+++ new/Statistics/Distribution/Gamma.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
230+++ new/Statistics/Distribution/Geometric.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
276+++ new/Statistics/Distribution/Hypergeometric.hs 2014-04-14 09:04:31.000000000 +0300
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-04-14 09:04:31.421509375 +0300
309+++ new/Statistics/Distribution/Normal.hs 2014-04-14 09:04:31.000000000 +0300
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,8 @@
317 import qualified Statistics.Distribution as D
318 import qualified Statistics.Sample as S
319 import qualified System.Random.MWC.Distributions as MWC
320+import Data.Binary (put, get)
321+import Control.Applicative ((<$>), (<*>))
325@@ -39,7 +41,9 @@
326 , ndCdfDenom :: {-# UNPACK #-} !Double
327 } deriving (Eq, Read, Show, Typeable, Data, Generic)
329-instance Binary NormalDistribution
330+instance Binary NormalDistribution where
331+ put (ND w x y z) = put w >> put x >> put y >> put z
332+ get = ND <$> get <*> get <*> get <*> get
334 instance D.Distribution NormalDistribution where
335 cumulative = cumulative
336diff -ru orig/Statistics/Distribution/Poisson/Internal.hs new/Statistics/Distribution/Poisson/Internal.hs
337--- orig/Statistics/Distribution/Poisson/Internal.hs 2014-04-14 09:04:31.421509375 +0300
338+++ new/Statistics/Distribution/Poisson/Internal.hs 2014-04-14 09:04:31.000000000 +0300
339@@ -36,8 +36,8 @@
340 -- | Compute entropy using Theorem 1 from "Sharp Bounds on the Entropy
341 -- of the Poisson Law". This function is unused because 'directEntorpy'
342 -- is just as accurate and is faster by about a factor of 4.
343-alyThm1 :: Double -> Double
344-alyThm1 lambda =
345+_alyThm1 :: Double -> Double
346+_alyThm1 lambda =
347 sum (takeWhile (\x -> abs x >= m_epsilon * lll) alySeries) + lll
348 where lll = lambda * (1 - log lambda)
349 alySeries =
350@@ -175,4 +175,4 @@
351 | lambda <= 18 = alyThm2 lambda upperCoefficients6 lowerCoefficients6
352 | lambda <= 24 = alyThm2 lambda upperCoefficients8 lowerCoefficients8
353 | lambda <= 30 = alyThm2 lambda upperCoefficients10 lowerCoefficients10
354- | otherwise = alyThm2 lambda upperCoefficients12 lowerCoefficients12
355\ No newline at end of file
356+ | otherwise = alyThm2 lambda upperCoefficients12 lowerCoefficients12
357diff -ru orig/Statistics/Distribution/Poisson.hs new/Statistics/Distribution/Poisson.hs
358--- orig/Statistics/Distribution/Poisson.hs 2014-04-14 09:04:31.421509375 +0300
359+++ new/Statistics/Distribution/Poisson.hs 2014-04-14 09:04:31.000000000 +0300
360@@ -1,4 +1,4 @@
361-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
362+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
363 -- |
364 -- Module : Statistics.Distribution.Poisson
365 -- Copyright : (c) 2009, 2011 Bryan O'Sullivan
366@@ -31,13 +31,20 @@
367 import qualified Statistics.Distribution.Poisson.Internal as I
368 import Numeric.SpecFunctions (incompleteGamma,logFactorial)
369 import Numeric.MathFunctions.Constants (m_neg_inf)
370+#if !MIN_VERSION_binary(0, 6, 0)
371+import Data.Binary (put, get)
372+#endif
375 newtype PoissonDistribution = PD {
376 poissonLambda :: Double
377 } deriving (Eq, Read, Show, Typeable, Data, Generic)
379-instance Binary PoissonDistribution
380+instance Binary PoissonDistribution where
381+#if !MIN_VERSION_binary(0, 6, 0)
382+ get = fmap PD get
383+ put = put . poissonLambda
384+#endif
386 instance D.Distribution PoissonDistribution where
387 cumulative (PD lambda) x
388@@ -78,8 +85,9 @@
389 poisson :: Double -> PoissonDistribution
390 poisson l
391 | l >= 0 = PD l
392- | otherwise = error $ "Statistics.Distribution.Poisson.poisson:\
393- \ lambda must be non-negative. Got " ++ show l
394+ | otherwise = error $
395+ "Statistics.Distribution.Poisson.poisson: lambda must be non-negative. Got "
396+ ++ show l
397 {-# INLINE poisson #-}
399 -- $references
400diff -ru orig/Statistics/Distribution/StudentT.hs new/Statistics/Distribution/StudentT.hs
401--- orig/Statistics/Distribution/StudentT.hs 2014-04-14 09:04:31.421509375 +0300
402+++ new/Statistics/Distribution/StudentT.hs 2014-04-14 09:04:31.000000000 +0300
403@@ -1,4 +1,4 @@
404-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
405+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
406 -- |
407 -- Module : Statistics.Distribution.StudentT
408 -- Copyright : (c) 2011 Aleksey Khudyakov
409@@ -23,12 +23,19 @@
410 import Statistics.Distribution.Transform (LinearTransform (..))
411 import Numeric.SpecFunctions (
412 logBeta, incompleteBeta, invIncompleteBeta, digamma)
413+#if !MIN_VERSION_binary(0, 6, 0)
414+import Data.Binary (put, get)
415+#endif
417 -- | Student-T distribution
418 newtype StudentT = StudentT { studentTndf :: Double }
419 deriving (Eq, Show, Read, Typeable, Data, Generic)
421-instance Binary StudentT
422+instance Binary StudentT where
423+#if !MIN_VERSION_binary(0, 6, 0)
424+ put = put . studentTndf
425+ get = fmap StudentT get
426+#endif
428 -- | Create Student-T distribution. Number of parameters must be positive.
429 studentT :: Double -> StudentT
430diff -ru orig/Statistics/Distribution/Transform.hs new/Statistics/Distribution/Transform.hs
431--- orig/Statistics/Distribution/Transform.hs 2014-04-14 09:04:31.421509375 +0300
432+++ new/Statistics/Distribution/Transform.hs 2014-04-14 09:04:31.000000000 +0300
433@@ -1,5 +1,5 @@
434 {-# LANGUAGE DeriveDataTypeable, DeriveGeneric, FlexibleContexts,
435- FlexibleInstances, UndecidableInstances #-}
436+ FlexibleInstances, UndecidableInstances, CPP #-}
437 -- |
438 -- Module : Statistics.Distribution.Transform
439 -- Copyright : (c) 2013 John McDonnell;
440@@ -21,6 +21,10 @@
441 import GHC.Generics (Generic)
442 import Data.Functor ((<$>))
443 import qualified Statistics.Distribution as D
444+#if !MIN_VERSION_binary(0, 6, 0)
445+import Data.Binary (put, get)
446+import Control.Applicative ((<*>))
447+#endif
449 -- | Linear transformation applied to distribution.
450 --
451@@ -35,7 +39,11 @@
452 -- ^ Distribution being transformed.
453 } deriving (Eq, Show, Read, Typeable, Data, Generic)
455-instance (Binary d) => Binary (LinearTransform d)
456+instance (Binary d) => Binary (LinearTransform d) where
457+#if !MIN_VERSION_binary(0, 6, 0)
458+ get = LinearTransform <$> get <*> get <*> get
459+ put (LinearTransform x y z) = put x >> put y >> put z
460+#endif
462 -- | Apply linear transformation to distribution.
463 scaleAround :: Double -- ^ Fixed point
464diff -ru orig/Statistics/Distribution/Uniform.hs new/Statistics/Distribution/Uniform.hs
465--- orig/Statistics/Distribution/Uniform.hs 2014-04-14 09:04:31.421509375 +0300
466+++ new/Statistics/Distribution/Uniform.hs 2014-04-14 09:04:31.000000000 +0300
467@@ -1,4 +1,4 @@
468-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
469+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP #-}
470 -- |
471 -- Module : Statistics.Distribution.Uniform
472 -- Copyright : (c) 2011 Aleksey Khudyakov
473@@ -24,6 +24,10 @@
474 import GHC.Generics (Generic)
475 import qualified Statistics.Distribution as D
476 import qualified System.Random.MWC as MWC
477+#if !MIN_VERSION_binary(0, 6, 0)
478+import Data.Binary (put, get)
479+import Control.Applicative ((<$>), (<*>))
480+#endif
483 -- | Uniform distribution from A to B
484@@ -32,7 +36,11 @@
485 , uniformB :: {-# UNPACK #-} !Double -- ^ Upper boundary of distribution
486 } deriving (Eq, Read, Show, Typeable, Data, Generic)
488-instance Binary UniformDistribution
489+instance Binary UniformDistribution where
490+#if !MIN_VERSION_binary(0, 6, 0)
491+ put (UniformDistribution x y) = put x >> put y
492+ get = UniformDistribution <$> get <*> get
493+#endif
495 -- | Create uniform distribution.
496 uniformDistr :: Double -> Double -> UniformDistribution
497diff -ru orig/Statistics/Math/RootFinding.hs new/Statistics/Math/RootFinding.hs
498--- orig/Statistics/Math/RootFinding.hs 2014-04-14 09:04:31.421509375 +0300
499+++ new/Statistics/Math/RootFinding.hs 2014-04-14 09:04:31.000000000 +0300
500@@ -1,4 +1,4 @@
501-{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric #-}
502+{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric, CPP #-}
504 -- |
505 -- Module : Statistics.Math.RootFinding
506@@ -27,6 +27,11 @@
507 import Control.Monad (MonadPlus(..), ap)
508 import Data.Data (Data, Typeable)
509 import GHC.Generics (Generic)
510+#if !MIN_VERSION_binary(0, 6, 0)
511+import Data.Binary (put, get)
512+import Data.Binary.Put (putWord8)
513+import Data.Binary.Get (getWord8)
514+#endif
517 -- | The result of searching for a root of a mathematical function.
518@@ -40,7 +45,20 @@
519 -- ^ A root was successfully found.
520 deriving (Eq, Read, Show, Typeable, Data, Generic)
522-instance (Binary a) => Binary (Root a)
523+instance (Binary a) => Binary (Root a) where
524+#if !MIN_VERSION_binary(0, 6, 0)
525+ put NotBracketed = putWord8 0
526+ put SearchFailed = putWord8 1
527+ put (Root a) = putWord8 2 >> put a
529+ get = do
530+ i <- getWord8
531+ case i of
532+ 0 -> return NotBracketed
533+ 1 -> return SearchFailed
534+ 2 -> fmap Root get
535+ _ -> fail $ "Root.get: Invalid value: " ++ show i
536+#endif
538 instance Functor Root where
539 fmap _ NotBracketed = NotBracketed
540diff -ru orig/Statistics/Resampling/Bootstrap.hs new/Statistics/Resampling/Bootstrap.hs
541--- orig/Statistics/Resampling/Bootstrap.hs 2014-04-14 09:04:31.421509375 +0300
542+++ new/Statistics/Resampling/Bootstrap.hs 2014-04-14 09:04:31.000000000 +0300
543@@ -1,5 +1,5 @@
544 {-# LANGUAGE DeriveDataTypeable, DeriveGeneric, OverloadedStrings,
545- RecordWildCards #-}
546+ RecordWildCards, CPP #-}
548 -- |
549 -- Module : Statistics.Resampling.Bootstrap
550@@ -35,6 +35,10 @@
551 import Statistics.Sample (mean)
552 import Statistics.Types (Estimator, Sample)
553 import qualified Data.Vector.Unboxed as U
554+#if !MIN_VERSION_binary(0, 6, 0)
555+import Data.Binary (put, get)
556+import Control.Applicative ((<$>), (<*>))
557+#endif
559 -- | A point and interval estimate computed via an 'Estimator'.
560 data Estimate = Estimate {
561@@ -50,7 +54,11 @@
562 -- ^ Confidence level of the confidence intervals.
563 } deriving (Eq, Read, Show, Typeable, Data, Generic)
565-instance Binary Estimate
566+instance Binary Estimate where
567+#if !MIN_VERSION_binary(0, 6, 0)
568+ put (Estimate w x y z) = put w >> put x >> put y >> put z
569+ get = Estimate <$> get <*> get <*> get <*> get
570+#endif
571 instance NFData Estimate
573 -- | Multiply the point, lower bound, and upper bound in an 'Estimate'
574diff -ru orig/Statistics/Resampling.hs new/Statistics/Resampling.hs
575--- orig/Statistics/Resampling.hs 2014-04-14 09:04:31.421509375 +0300
576+++ new/Statistics/Resampling.hs 2014-04-14 09:04:31.000000000 +0300
577@@ -1,4 +1,4 @@
578-{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric #-}
579+{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric, CPP #-}
581 -- |
582 -- Module : Statistics.Resampling
583@@ -42,7 +42,11 @@
584 fromResample :: U.Vector Double
585 } deriving (Eq, Read, Show, Typeable, Data, Generic)
587-instance Binary Resample
588+instance Binary Resample where
589+#if !MIN_VERSION_binary(0, 6, 0)
590+ put = put . fromResample
591+ get = fmap Resample get
592+#endif
594 -- | /O(e*r*s)/ Resample a data set repeatedly, with replacement,
595 -- computing each estimate over the resampled data.
596diff -ru orig/Statistics/Sample/KernelDensity/Simple.hs new/Statistics/Sample/KernelDensity/Simple.hs
597--- orig/Statistics/Sample/KernelDensity/Simple.hs 2014-04-14 09:04:31.425509375 +0300
598+++ new/Statistics/Sample/KernelDensity/Simple.hs 2014-04-14 09:04:31.000000000 +0300
599@@ -1,4 +1,4 @@
600-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, FlexibleContexts #-}
601+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, FlexibleContexts, CPP #-}
602 -- |
603 -- Module : Statistics.Sample.KernelDensity.Simple
604 -- Copyright : (c) 2009 Bryan O'Sullivan
605@@ -61,7 +61,11 @@
606 fromPoints :: U.Vector Double
607 } deriving (Eq, Read, Show, Typeable, Data, Generic)
609-instance Binary Points
610+instance Binary Points where
611+#if !MIN_VERSION_binary(0, 6, 0)
612+ get = fmap Points get
613+ put = put . fromPoints
614+#endif
616 -- | Bandwidth estimator for an Epanechnikov kernel.
617 epanechnikovBW :: Double -> Bandwidth
618diff -ru orig/Statistics/Sample/Powers.hs new/Statistics/Sample/Powers.hs
619--- orig/Statistics/Sample/Powers.hs 2014-04-14 09:04:31.421509375 +0300
620+++ new/Statistics/Sample/Powers.hs 2014-04-14 09:04:31.000000000 +0300
621@@ -1,5 +1,5 @@
622 {-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric,
623- FlexibleContexts #-}
624+ FlexibleContexts, CPP #-}
625 -- |
626 -- Module : Statistics.Sample.Powers
627 -- Copyright : (c) 2009, 2010 Bryan O'Sullivan
628@@ -65,7 +65,11 @@
629 newtype Powers = Powers (U.Vector Double)
630 deriving (Eq, Read, Show, Typeable, Data, Generic)
632-instance Binary Powers
633+instance Binary Powers where
634+#if !MIN_VERSION_binary(0, 6, 0)
635+ put (Powers v) = put v
636+ get = fmap Powers get
637+#endif
639 -- | O(/n/) Collect the /n/ simple powers of a sample.
640 --
641diff -ru orig/statistics.cabal new/statistics.cabal
642--- orig/statistics.cabal 2014-04-14 09:04:31.429509375 +0300
643+++ new/statistics.cabal 2014-04-14 09:04:31.000000000 +0300
644@@ -90,7 +90,7 @@
645 Statistics.Test.Internal
646 build-depends:
647 base < 5,
648- binary >= 0.6.3.0,
649+ binary >= 0.5.1.0,
650 deepseq >= 1.1.0.2,
651 erf,
652 monad-par >= 0.3.4,
653diff -ru orig/tests/Tests/Distribution.hs new/tests/Tests/Distribution.hs
654--- orig/tests/Tests/Distribution.hs 2014-04-14 09:04:31.425509375 +0300
655+++ new/tests/Tests/Distribution.hs 2014-04-14 09:04:31.000000000 +0300
656@@ -188,7 +188,7 @@
658 -- Quantile is inverse of CDF
659 quantileIsInvCDF :: (Param d, ContDistr d) => T d -> d -> Double -> Property
660-quantileIsInvCDF _ d (snd . properFraction -> p) =
661+quantileIsInvCDF _ d ((snd :: (Int, y) -> y) . properFraction -> p) =
662 p > 0 && p < 1 ==> ( printTestCase (printf "Quantile = %g" q )
663 $ printTestCase (printf "Probability = %g" p )
664 $ printTestCase (printf "Probability' = %g" p')
665@@ -203,8 +203,8 @@
666 quantileShouldFail :: (ContDistr d) => T d -> d -> Double -> Property
667 quantileShouldFail _ d p =
668 p < 0 || p > 1 ==> QC.monadicIO $ do r <- QC.run $ catch
669- (do { return $! quantile d p; return False })
670- (\(e :: SomeException) -> return True)
671+ (do { _ <- return $! quantile d p; return False })
672+ (\(_e :: SomeException) -> return True)
673 QC.assert r
676diff -ru orig/tests/Tests/Function.hs new/tests/Tests/Function.hs
677--- orig/tests/Tests/Function.hs 2014-04-14 09:04:31.425509375 +0300
678+++ new/tests/Tests/Function.hs 2014-04-14 09:04:31.000000000 +0300
679@@ -1,7 +1,6 @@
680 module Tests.Function ( tests ) where
682 import qualified Data.Vector.Unboxed as U
683-import Data.Vector.Unboxed ((!))
685 import Test.QuickCheck
686 import Test.Framework
687@@ -29,5 +28,5 @@
688 p_nextHighestPowerOfTwo
689 = all (\(good, is) -> all ((==good) . nextHighestPowerOfTwo) is) lists
690 where
691- pows = [1 .. 17]
692+ pows = [1 .. 17 :: Int]
693 lists = [ (2^m, [2^n+1 .. 2^m]) | (n,m) <- pows `zip` tail pows ]
694diff -ru orig/tests/Tests/Transform.hs new/tests/Tests/Transform.hs
695--- orig/tests/Tests/Transform.hs 2014-04-14 09:04:31.425509375 +0300
696+++ new/tests/Tests/Transform.hs 2014-04-14 09:04:31.000000000 +0300
697@@ -15,7 +15,7 @@
698 import Test.Framework (Test, testGroup)
699 import Test.Framework.Providers.QuickCheck2 (testProperty)
700 import Test.QuickCheck (Positive(..),Property,Arbitrary(..),Gen,choose,vectorOf,
701- printTestCase, quickCheck)
702+ printTestCase)
704 import Text.Printf