[documentation
ekmett@gmail.com**20090327051247] {
hunk ./dist/doc/html/monoids/Data-Monoid-Generator.html 261
+> IntSet
Reducer (IntMap a) (Union a) | Reducer (IntMap a) (Union a) | | Ord k => Reducer (Map k a) (Union k a) | Ord k => Reducer (Map k a) (Union k a) | getUnion1 (Function) | Data.Monoid.Map | 2 (Function) | Data.Monoid.IntMap | Keys | 1 (Type/Class) | Data.Monoid.Generator, Data.Monoid.Generator.Combinators | 2 (Data Constructor) | Data.Monoid.Generator, Data.Monoid.Generator.Combinators | Union | 1 (Type/Class) | Data.Monoid.Map | 2 (Type/Class) | Data.Monoid.IntMap | | Values | 1 (Type/Class) | Data.Monoid.Generator, Data.Monoid.Generator.Combinators | 2 (Data Constructor) | Data.Monoid.Generator, Data.Monoid.Generator.Combinators | ) where
-
-import Data.Word (Word8)
-import Data.Text (Text)
-import Data.Foldable (fold,foldMap)
-import qualified Data.Text as Text
-import qualified Data.ByteString as Strict
-import qualified Data.ByteString.Lazy as Lazy
-import Control.Parallel.Strategies
-import Data.Monoid.Reducer
-import Data.Sequence (Seq)
-import Data.FingerTree (Measured, FingerTree)
-
-
-class Generator c where
- type Elem c :: *
- mapReduce :: (e `Reducer` m) => (Elem c -> e) -> c -> m
- mapTo :: (e `Reducer` m) => (Elem c -> e) -> m -> c -> m
- mapFrom :: (e `Reducer` m) => (Elem c -> e) -> c -> m -> m
-
- mapReduce f = mapTo f mempty
- mapTo f m = mappend m . mapReduce f
- mapFrom f = mappend . mapReduce f
-
-instance Generator Strict.ByteString where
- type Elem Strict.ByteString = Word8
- mapTo f = Strict.foldl' (\a -> snoc a . f)
+ , Keys(Keys)
+ , Values(Values)
+ ) where
+
+import Data.Word (Word8)
+import Data.Text (Text)
+import Data.Foldable (fold,foldMap)
+import qualified Data.Text as Text
+import qualified Data.ByteString as Strict
+
+import qualified Data.ByteString.Lazy as Lazy
+
+import qualified Data.Sequence as Seq
+import Data.Sequence (Seq)
+import qualified Data.Set as Set
+import Data.Set (Set)
+import qualified Data.IntSet as IntSet
+import Data.IntSet (IntSet)
+import qualified Data.IntMap as IntMap
+import Data.IntMap (IntMap)
+import qualified Data.Map as Map
+import Data.Map (Map)
+
+import Control.Parallel.Strategies
+import Data.Monoid.Reducer
+import Data.Sequence (Seq)
+import Data.FingerTree (Measured, FingerTree)
hunk ./dist/doc/html/monoids/src/Data-Monoid-Generator.html 46
-instance Generator Lazy.ByteString where
- type Elem Lazy.ByteString = Elem Strict.ByteString
- mapReduce f = fold . parMap rwhnf (mapReduce f) . Lazy.toChunks
-
-instance Generator Text where
- type Elem Text = Char
- mapTo f = Text.foldl' (\a -> snoc a . f)
-
-instance Generator [c] where
- type Elem [c] = c
- mapReduce f = foldMap (unit . f)
-
-instance Measured v m => Generator (FingerTree v m) where
- type Elem (FingerTree v m) = m
- mapReduce f = foldMap (unit . f)
-
-instance Generator (Seq c) where
- type Elem (Seq c) = c
- mapReduce f = foldMap (unit . f)
-
-
-
-
-
-
-
-reduce :: (Generator c, Elem c `Reducer` m) => c -> m
-reduce = mapReduce id
+
+class Generator c where
+ type Elem c :: *
+ mapReduce :: (e `Reducer` m) => (Elem c -> e) -> c -> m
+ mapTo :: (e `Reducer` m) => (Elem c -> e) -> m -> c -> m
+ mapFrom :: (e `Reducer` m) => (Elem c -> e) -> c -> m -> m
+
+ mapReduce f = mapTo f mempty
+ mapTo f m = mappend m . mapReduce f
+ mapFrom f = mappend . mapReduce f
+
+instance Generator Strict.ByteString where
+ type Elem Strict.ByteString = Word8
+ mapTo f = Strict.foldl' (\a -> snoc a . f)
+
+instance Generator Lazy.ByteString where
+ type Elem Lazy.ByteString = Word8
+ mapReduce f = fold . parMap rwhnf (mapReduce f) . Lazy.toChunks
+
+
+
+instance Generator Text where
+ type Elem Text = Char
+ mapTo f = Text.foldl' (\a -> snoc a . f)
+
+instance Generator [c] where
+ type Elem [c] = c
+ mapReduce f = foldMap (unit . f)
+
+instance Measured v e => Generator (FingerTree v e) where
+ type Elem (FingerTree v e) = e
+ mapReduce f = foldMap (unit . f)
+
+instance Generator (Seq c) where
+ type Elem (Seq c) = c
+ mapReduce f = foldMap (unit . f)
+
+instance Generator IntSet where
+ type Elem IntSet = Int
+ mapReduce f = mapReduce f . IntSet.toList
+
+instance Generator (Set a) where
+ type Elem (Set a) = a
+ mapReduce f = mapReduce f . Set.toList
+
+instance Generator (IntMap v) where
+ type Elem (IntMap v) = (Int,v)
+ mapReduce f = mapReduce f . IntMap.toList
+
+instance Generator (Map k v) where
+ type Elem (Map k v) = (k,v)
+ mapReduce f = mapReduce f . Map.toList
+
+newtype Keys c = Keys { getKeys :: c }
+
+instance Generator (Keys (IntMap v)) where
+ type Elem (Keys (IntMap v)) = Int
+ mapReduce f = mapReduce f . IntMap.keys . getKeys
+
+instance Generator (Keys (Map k v)) where
+ type Elem (Keys (Map k v)) = k
+ mapReduce f = mapReduce f . Map.keys . getKeys
+
+newtype Values c = Values { getValues :: c }
+
+instance Generator (Values (IntMap v)) where
+ type Elem (Values (IntMap v)) = v
+ mapReduce f = mapReduce f . IntMap.elems . getValues
+
+instance Generator (Values (Map k v)) where
+ type Elem (Values (Map k v)) = v
+ mapReduce f = mapReduce f . Map.elems . getValues
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+reduce :: (Generator c, Elem c `Reducer` m) => c -> m
+reduce = mapReduce id
hunk ./dist/doc/html/monoids/src/Data-Monoid-IntMap.html 12
- , Union(getUnion)
- , UnionWith(getUnionWith)
- ) where
-
-import Data.Monoid.Reducer (Reducer, unit, cons, snoc, Monoid, mappend, mempty)
-import Data.IntMap
-
-newtype Union a = Union { getUnion :: IntMap a }
-
-instance Monoid (Union a) where
- mempty = Union empty
- Union a `mappend` Union b = Union (a `union` b)
-
-instance Reducer (IntMap a) (Union a) where
- unit = Union
-
-
-
-newtype UnionWith m = UnionWith { getUnionWith :: IntMap m }
-
-instance Monoid m => Monoid (UnionWith m) where
- mempty = UnionWith empty
- UnionWith a `mappend` UnionWith b = UnionWith (unionWith mappend a b)
-
-instance Monoid m => Reducer (IntMap m) (UnionWith m) where
- unit = UnionWith
+ , UnionWith(getUnionWith)
+ ) where
+
+import Data.Monoid.Reducer (Reducer, unit, cons, snoc, Monoid, mappend, mempty)
+import Data.IntMap
+
+newtype UnionWith m = UnionWith { getUnionWith :: IntMap m }
+
+instance Monoid m => Monoid (UnionWith m) where
+ mempty = UnionWith empty
+ UnionWith a `mappend` UnionWith b = UnionWith (unionWith mappend a b)
+
+instance Monoid m => Reducer (IntMap m) (UnionWith m) where
+ unit = UnionWith
hunk ./dist/doc/html/monoids/src/Data-Monoid-Map.html 12
- , Union(getUnion)
- , UnionWith(getUnionWith)
- ) where
-
-import Prelude (Ord)
-import Data.Monoid.Reducer (Reducer, unit, cons, snoc, Monoid, mempty, mappend)
-import Data.Map
-
-newtype Union k a = Union { getUnion :: Map k a }
-
-instance Ord k => Monoid (Union k a) where
- mempty = Union empty
- Union a `mappend` Union b = Union (a `union` b)
-
-instance Ord k => Reducer (Map k a) (Union k a) where
- unit = Union
-
-
-
-newtype UnionWith k m = UnionWith { getUnionWith :: Map k m }
-
-instance (Ord k, Monoid m) => Monoid (UnionWith k m) where
- mempty = UnionWith empty
- UnionWith a `mappend` UnionWith b = UnionWith (unionWith mappend a b)
-
-instance (Ord k, Monoid m) => Reducer (Map k m) (UnionWith k m) where
- unit = UnionWith
+ , UnionWith(getUnionWith)
+ ) where
+
+import Prelude (Ord)
+import Data.Monoid.Reducer (Reducer, unit, cons, snoc, Monoid, mempty, mappend)
+import Data.Map
+
+
+
+newtype UnionWith k m = UnionWith { getUnionWith :: Map k m }
+
+instance (Ord k, Monoid m) => Monoid (UnionWith k m) where
+ mempty = UnionWith empty
+ UnionWith a `mappend` UnionWith b = UnionWith (unionWith mappend a b)
+
+instance (Ord k, Monoid m) => Reducer (Map k m) (UnionWith k m) where
+ unit = UnionWith
hunk ./dist/doc/html/monoids/src/Data-Monoid-Multiplicative.html 21
-import Data.Foldable
-import qualified Data.Sequence as Seq
-import Data.Sequence (Seq)
-
-class MultiplicativeMonoid m where
- one :: m
- times :: m -> m -> m
-
-class (MultiplicativeMonoid m, Monoid m) => Seminearring m
-
-instance Monoid m => MultiplicativeMonoid [m] where
- one = [mempty]
- xss `times` yss = [ xs `mappend` ys | xs <- xss, ys <- yss ]
-
-instance Monoid m => Seminearring [m]
-
-instance (Measured v m, Monoid m) => MultiplicativeMonoid (FingerTree v m) where
- one = singleton mempty
- xss `times` yss = getSelf $ mapReduce (flip fmap' yss . mappend) xss
-
-instance (Monoid m) => MultiplicativeMonoid (Seq m) where
- one = Seq.singleton mempty
- xss `times` yss = getSelf $ mapReduce (flip fmap yss . mappend) xss
-
-instance (Measured v m, Monoid m) => Seminearring (FingerTree v m)
-
-instance MultiplicativeMonoid m => MultiplicativeMonoid (Self m) where
- one = Self one
- Self a `times` Self b = Self (a `times` b)
-
-instance MultiplicativeMonoid m => MultiplicativeMonoid (FromString m) where
- one = FromString one
- FromString a `times` FromString b = FromString (a `times` b)
-
-
+import qualified Data.Sequence as Seq
+import Data.Sequence (Seq)
+
+class MultiplicativeMonoid m where
+ one :: m
+ times :: m -> m -> m
+
+class (MultiplicativeMonoid m, Monoid m) => Seminearring m
+
+instance Monoid m => MultiplicativeMonoid [m] where
+ one = [mempty]
+ xss `times` yss = [ xs `mappend` ys | xs <- xss, ys <- yss ]
+
+instance Monoid m => Seminearring [m]
+
+instance (Measured v m, Monoid m) => MultiplicativeMonoid (FingerTree v m) where
+ one = singleton mempty
+ xss `times` yss = getSelf $ mapReduce (flip fmap' yss . mappend) xss
+
+instance (Monoid m) => MultiplicativeMonoid (Seq m) where
+ one = Seq.singleton mempty
+ xss `times` yss = getSelf $ mapReduce (flip fmap yss . mappend) xss
+
+instance (Measured v m, Monoid m) => Seminearring (FingerTree v m)
+
+instance MultiplicativeMonoid m => MultiplicativeMonoid (Self m) where
+ one = Self one
+ Self a `times` Self b = Self (a `times` b)
+
+instance MultiplicativeMonoid m => MultiplicativeMonoid (FromString m) where
+ one = FromString one
+ FromString a `times` FromString b = FromString (a `times` b)
+
+
}
|