let filter (f : 'e -> bool) (s : 'e hashset) : 'e list = fold (fun x acc -> if f x then x::acc else acc) s []