
On 09/11/13 10:28, Edward Kmett wrote:
We can't just upgrade those classes to be type family based, as this destroys their support for polymorphic recursion.
We could write another class though.
The question is if that class belongs in base or in some other package, as it takes is pretty far afield of anything purporting to be portable.
Not necessarily. If you get rid of the item type, the resulting class is standard Haskell: class Monoid m => FactorialMonoid m where foldMap :: (FactorialMonoid m, Monoid n) => (m -> n) -> m -> n With this approach you're folding over the atomic factors of the ByteString, i.e., ByteStrings containing 1 byte each, rather than the bytes themselves. The same interface covers strict and lazy ByteString and ByteString.Char8 as well. Yes, abstracting away the item type would have some performance impact, as foldMap would need to construct the singleton ByteStrings. I'm hoping they could be deforested away.