reducers 0.1.1 → 0.1.2
raw patch · 3 files changed
+29/−2 lines, 3 files
Files
- Data/Semigroup/Reducer.hs +15/−1
- Data/Semigroup/Reducer/With.hs +5/−0
- reducers.cabal +9/−1
Data/Semigroup/Reducer.hs view
@@ -28,6 +28,7 @@ import Data.Semigroup as Semigroup import Data.Semigroup.Foldable import Data.Semigroup.Instances ()+import Data.Hashable import Data.Foldable import Data.FingerTree @@ -42,6 +43,10 @@ import qualified Data.Map as Map import Data.Map (Map) +#ifdef LANGUAGE_DeriveDataTypeable+import Data.Data+#endif+ --import Text.Parsec.Prim -- | This type may be best read infix. A @c `Reducer` m@ is a 'Semigroup' @m@ that maps@@ -92,7 +97,16 @@ pureUnit :: (Applicative f, Reducer c n) => c -> f n pureUnit = pure . unit -newtype Count = Count { getCount :: Int } deriving (Eq,Ord,Show,Read)+newtype Count = Count { getCount :: Int } deriving + ( Eq, Ord, Show, Read+#ifdef LANGUAGE_DeriveDataTypeable+ , Data, Typeable+#endif+ )++instance Hashable Count where+ hash = hash . getCount+ hashWithSalt n = hashWithSalt n . getCount instance Semigroup Count where Count a <> Count b = Count (a + b)
Data/Semigroup/Reducer/With.hs view
@@ -19,6 +19,7 @@ import Data.FingerTree import Data.Foldable import Data.Traversable+import Data.Hashable import Data.Monoid import Data.Semigroup.Reducer import Data.Semigroup.Foldable@@ -31,6 +32,10 @@ newtype WithReducer m c = WithReducer { withoutReducer :: c } deriving (Eq, Ord, Show, Read)++instance Hashable c => Hashable (WithReducer m c) where+ hash = hash . withoutReducer+ hashWithSalt n = hashWithSalt n . withoutReducer instance Functor (WithReducer m) where fmap f = WithReducer . f . withoutReducer
reducers.cabal view
@@ -1,6 +1,6 @@ name: reducers category: Data, Math, Numerical, Semigroups-version: 0.1.1+version: 0.1.2 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -17,6 +17,10 @@ type: git location: git://github.com/ekmett/reducers.git +flag DeriveDataTypeable+ manual: False+ default: True+ library build-depends: base >= 4 && < 5,@@ -50,5 +54,9 @@ Data.Semigroup.Monad Data.Semigroup.MonadPlus Data.Semigroup.Self++ if flag(DeriveDataTypeable)+ extensions: DeriveDataTypeable+ cpp-options: -DLANGUAGE_DeriveDataTypeable ghc-options: -Wall