On Jun 2, 2005, at 10:29 AM, Mario Blazevic wrote:
...
3. The Data.Map looks much better than the FiniteMap library, and its
export list is very complete. There are, however, two (or four) more
functions that would be really nice to have in there, as they are
impossible to write
This being the topic, I'll list the issues I ran into with the new
Data.Map library:
1. The function Map.union is left-biased whereas the old
FiniteMap.unionFM was right-biased. The change seems rather arbitrary.
There are also other changes of this kind, the following two notable
among
Mario Blazevic wrote:
mapFilter :: (a - Maybe b) - Map k a - Map k b
mapFilter f = map Maybe.fromJust . filter Maybe.isJust . map f
How about using Map.foldWithKey (and adding Ord k = to the type
signature)?
mapFilter f = Map.foldWithKey ( \ k - maybe id (Map.insert k) . f)
Map.empty
Christian Maeder wrote:
Mario Blazevic wrote:
mapFilter :: (a - Maybe b) - Map k a - Map k b
mapFilter f = map Maybe.fromJust . filter Maybe.isJust . map f
How about using Map.foldWithKey (and adding Ord k = to the type
signature)?
mapFilter f = Map.foldWithKey ( \ k - maybe id