Jacques Garrigue <garri...@math.nagoya-u.ac.jp> writes: > type 'a base = {x : 'a; fn : 'a -> unit} > type 'b base_op = {bop: 'a. 'a base -> 'b} > type base_wrapper = {base: 'b. 'b base_op -> 'b} > > let l = > let a = {x = 1; fn = print_int} > and b = {x = 1.2; fn = print_float} in > [{base = fun x -> x.bop a}; {base = fun x -> x.bop b}] > > List.iter (fun w -> w.base {bop = fun r -> r.fn r.x}) l > > As you can see, the result is rather verbose, but this works. > Fortunately, closure and objects are usually enough... > > Jacques Garrigue
That is exactly what I ment. I knew closures could have "'a. ..." types but I didn't think of encoding the record and the method to call both as closures. MfG Goswin _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs