
Tomasz Zielonka
Hmmm...I have perhaps a rather shallow reason. When using a FiniteMap to collect lists of values, I think it will be more efficient to use (flip (++)), prepending instead of appending each new element.
If (flip (++)) is efficient for one interface, shouldn't (++) be as efficient for the other?
Yes. Sorry if that wasn't clear; my point was that the new interface saves you the 'flip' -- or alternatively, the naive user not considering these issues will likely just use (++), which may be more efficient for the new interface.
Why not use efficient catenable sequences or a ShowS trick, like here:
groupFM :: Ord a => [(a, b)] -> FiniteMap a [b] groupFM l = mapFM (\_ -> ($ [])) $ addListToFM_C (.) emptyFM [ (a, (b:)) | (a, b) <- l ]
Because it is more complex? It's a neat trick, but it does takes me a minute or two to see what's going on. Perhaps groupFM should be part of (Finite)Map? -kzm -- If I haven't seen further, it is by standing in the footprints of giants