[Haskell-cafe] Monomorphic containers, Functor/Foldable/Traversable WAS: mapM_ for bytestring
Mario Blažević
blamario at acanac.net
Fri Sep 13 04:38:58 CEST 2013
On 09/11/13 19:37, John Lato wrote:
> I didn't see this message and replied privately to Michael earlier, so
> I'm replicating my comments here.
>
> 1. Sooner or later I expect you'll want something like this:
>
> class LooseMap c el el' where
>
>
> lMap :: (el -> el') -> c el -> c el'
>
> It covers the case of things like hashmaps/unboxed vectors that have
> class constraints on elements. Although maybe LooseFunctor or LFunctor
> is a better name.
>
> Probably something similar for Traversable would be good also, as would
> a default instance in terms of Functor.
>
> 2. IMHO cMapM_ (and related) should be part of the Foldable class.
> This is entirely for performance reasons, but there's no downside since
> you can just provide a default instance.
>
> 3. I'm not entirely sure that the length* functions belong here. I
> understand why, and I think it's sensible reasoning, and I don't have a
> good argument against it, but I just don't like it. With those, and
> mapM_-like functions, it seems that the foldable class is halfway to
> being another monolithic ListLike. But I don't have any better ideas
> either.
If monolithic classes bother you, my monoid-subclasses package manages
to break down the functionality into several classes. One big difference
is that everything is based off Monoid rather than Foldable, and that
has some big effects on the interface.
More information about the Haskell-Cafe
mailing list