Jake McArthur wrote:
The monoids package offers something similar to this:
mapReduce :: (Generator c, Reducer e m) => (Elem c -> e) -> c -> m
If we take (Elem c) to be (item), (e) to be (item'), (c) to be (full),
and (m) to be (full'), it's basically the same thing, and offers the
same advantages as the ones you listed, as far as I can tell.
Your example about uvector inspired me to try writing out the necessary
instances for uvector:
instance UA a => Monoid (UArr a) where
mempty = emptyU
mappend = appendU
instance UA a => Reducer a (UArr a) where
unit = singletonU
snoc = snocU
cons = consU
instance UA a => Generator (UArr a) where
type Elem (UArr a) = a
mapTo f = foldlU (\a -> snoc a . f)
- Jake
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe