Re: Map library

2005-06-03 Thread Jan-Willem Maessen
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

Re: Map library

2005-06-02 Thread Mario Blazevic
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

Re: Map library

2005-06-02 Thread Christian Maeder
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

Re: Map library

2005-06-02 Thread Mario Blazevic
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