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