let filter p s = Name.Map.fold (fun n e acc -> if p n e then Name.Map.add n e acc else acc) s Name.Map.empty