fromListWith should be generalized to Foldable, and we need fromListMap functions (Foldable t, Monoid m) => (a -> m) -> t (k, a) -> Map k m and perhaps (Foldable t, Monoid m) => (k -> m) -> t k -> Map k m. Admittedly the last one is probably just to implement histogram :: Foldable t => t k -> Map k Int, but in the end even putting histogram itself into Data.Map would be ok in my book.
fromListWith
should be generalized toFoldable
, and we needfromListMap
functions(Foldable t, Monoid m) => (a -> m) -> t (k, a) -> Map k m
and perhaps(Foldable t, Monoid m) => (k -> m) -> t k -> Map k m
. Admittedly the last one is probably just to implementhistogram :: Foldable t => t k -> Map k Int
, but in the end even puttinghistogram
itself intoData.Map
would be ok in my book.