Browse thread
[Caml-list] Conditional Modules
[
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: | -- (:) |
| From: | Jean-Baptiste Rouquier <jrouquiethearchiveshouldhaveafewantispamtricks@e...> |
| Subject: | Re: [Caml-list] Conditional Modules |
Ross Duncan wrote: > module type T = > sig > type t > (* some other stuff involving t *) > end > > module M1 : T = .... > module M2 : T = .... > > (* and now choose at runtime between M1 and M2 *) > > It seems that all the *other stuff* can be chosen at runtime with various degrees of elegance but the type t is the big spanner which stops the machine. Is the following what you need ? module F (M:T) = struct let main () = ... end let () = match int_of_string Sys.argv.(1) with | 1 -> let module A = F(M1) in A.main () | 2 -> let module A = F(M2) in A.main () | _ -> Printf.eprintf ... Jean-Baptiste. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners