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 mapPartition f = Map.foldWithKey ( \ k v (l, r) -> either ( \ x -> (Map.insert k x l, r)) ( \ x -> (l, Map.insert k x r)) $ f v) (Map.empty, Map.empty) Could it be more efficient? Cheers Christian _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users