[Haskell-cafe] containers and maps

Jake McArthur jake.mcarthur at gmail.com
Thu Aug 13 00:12:27 EDT 2009

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

More information about the Haskell-Cafe mailing list