@@ -351,3 +351,9 @@ toList t = foldr (\k v acc -> (k,v) :: acc) [] t
351{-| Convert an association list into a dictionary. -}
351{-| Convert an association list into a dictionary. -}
352fromList : [(comparable,v)] -> Dict comparable v
352fromList : [(comparable,v)] -> Dict comparable v
353fromList assocs = List.foldl (\(k,v) d -> insert k v d) empty assocs
353fromList assocs = List.foldl (\(k,v) d -> insert k v d) empty assocs
355+{-| Keep only key-value pairs where the value satisfies a predicate. -}
356+filter : (v -> Bool) -> Dict comparable v -> Dict comparable v
358+ let add k v t = if p v then insert k v t else t
359+ in foldl combine empty