Browse thread
Type from local module would escape its scope?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-07-03 (15:10) |
From: | Jonathan Roewen <jonathan.roewen@g...> |
Subject: | Re: [Caml-list] Type from local module would escape its scope? |
> Thanks for your explanations! To get closer to the problem that > caused me to investigate the error: so there is no way to make f1 > into an argument in the following function iter_uniques (other than > as a method or record field)? > > let f1 add empty = List.fold_right add ["foo"; "bar"; "bar"] empty ;; > let f2 = print_endline ;; > > let iter_uniques comparison_fun = > let module StringSet = > Set.Make(struct > type t = string > let compare = comparison_fun > end) in StringSet.iter f2 (f1 StringSet.add StringSet.empty) > ;; Hmm, you could use a ref (which yes, is a record type). let dyn_comparer = ref compare let dyn_compare a b = !dyn_comparer a b module SS = Set.Make(struct type t = string let compare = dyn_compare end);; let iter_uniques f1 f2 = SS.iter f2 (f1 SS.add SS.empty);;