I agree with everything Edward has said already. I went through a
similar chain of reasoning a few years ago when I started using
ListLike, which provides a FoldableLL class (although it uses fundeps as
ListLike predates type families). ByteString can't be a Foldable instance, nor do I think most people would want it to be.
Petr Pudlak has done some work in this area. A big problem is that foldM/mapM_ are typically implemented in terms of Foldable.foldr (or FoldableLL), but this isn't always optimal for performance. They really need to be part of the type class so that different container types can have specialized implementations. I did that in mono-foldable, using Artyom's map implementation (Artyom, please let me know if you object to this!)
pull requests, forks, etc all welcome.
John L.