On 03/02/2010 11:05, Tiphaine Turpin wrote:
It is possible however, provided you wrap the argument inside a
polymorphic record field (or object) as follows:
type t = {f : 'a. 'a -> 'a}
let test f =
let module Foo : Foo_sig =
struct
let foo = f.f
end
in
()
Another option (that will be available in OCaml 3.12) is to build the
module as a first-class value outside the function "test".
=================================
module type Foo_sig = sig
val f: 'a -> 'a
end
let test foo =
let module Foo = (val foo : Foo_sig) in
(* use the polymorphic function here... *)
()
let () =
let foo_impl = (module struct let f a = a end : Foo_sig) in
test foo_impl
=================================
The type for test is:
val test : (module Foo_sig) -> unit
Alain
_______________________________________________
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