Commits

Aleksey Khudyakov  committed 915f79c

Add Typable,Eq and Ord (where applicable) to the monoids

  • Participants
  • Parent commits b625f10

Comments (0)

Files changed (2)

File Data/Monoid/Statistics.hs

 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE BangPatterns          #-}
+{-# LANGUAGE DeriveDataTypeable    #-}
 -- |
 -- Module     : Data.Monoid.Statistics
 -- Copyright  : Copyright (c) 2010, Alexey Khudyakov <alexey.skladnoy@gmail.com>
 
 
 import Data.Monoid
+import Data.Typeable (Typeable)
 import qualified Data.Foldable as F
 
 
 data TwoStats a b = TwoStats { calcStat1 :: !a
                              , calcStat2 :: !b
                              }
+                    deriving (Show,Eq,Typeable)
 
 instance (Monoid a, Monoid b) => Monoid (TwoStats a b) where
   mempty = TwoStats mempty mempty

File Data/Monoid/Statistics/Numeric.hs

-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE BangPatterns          #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE DeriveDataTypeable    #-}
 module Data.Monoid.Statistics.Numeric ( 
     -- * Mean and variance
     Count(..)
 
 import Data.Monoid
 import Data.Monoid.Statistics
-
+import Data.Typeable (Typeable)
 
 ----------------------------------------------------------------
 -- Statistical monoids
 
 -- | Simplest statistics. Number of elements in the sample
 newtype Count a = Count { calcCountI :: a }
-                  deriving Show
+                  deriving (Show,Eq,Ord,Typeable)
 
 -- | Fix type of monoid
 asCount :: Count a -> Count a
 -- Numeric stability of 'mappend' is not proven.
 data Mean = Mean {-# UNPACK #-} !Int    -- Number of entries
                  {-# UNPACK #-} !Double -- Current mean
-            deriving Show
+            deriving (Show,Eq,Typeable)
 
 -- | Fix type of monoid
 asMean :: Mean -> Mean
 data Variance = Variance {-# UNPACK #-} !Int    --  Number of elements in the sample
                          {-# UNPACK #-} !Double -- Current sum of elements of sample
                          {-# UNPACK #-} !Double -- Current sum of squares of deviations from current mean
-                deriving Show
+                deriving (Show,Eq,Typeable)
 
 -- | Fix type of monoid
 asVariance :: Variance -> Variance
 -- | Calculate minimum of sample. For empty sample returns NaN. Any
 -- NaN encountedred will be ignored. 
 newtype Min = Min { calcMin :: Double }
-              deriving Show
+              deriving (Show,Eq,Ord,Typeable)
 
 -- N.B. forall (x :: Double) (x <= NaN) == False
 instance Monoid Min where
 -- | Calculate maximum of sample. For empty sample returns NaN. Any
 -- NaN encountedred will be ignored. 
 newtype Max = Max { calcMax :: Double }
-              deriving Show
+              deriving (Show,Eq,Ord,Typeable)
 
 instance Monoid Max where
   mempty = Max (0/0)