* [Caml-list] Conditional Modules @ 2004-08-04 14:58 Ross Duncan 2004-08-04 16:02 ` Richard Jones ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Ross Duncan @ 2004-08-04 14:58 UTC (permalink / raw) To: caml-list Forgive me for asking what might be an easy question, I am just a beginner with Ocaml. I want to do something like this: module M = if arg then M1 else M2 module A = F (M) (* define rest of program using fields of A *) The idea being that arg will come from e.g. the command line, and modules M1, M2 and functor F are defined elsewhere. Of course "module M = if ... " is a syntax error. My question is: how to achieve this behaviour (and generalisations of it) in ocaml? It seems that this is an obvious thing to want to do but I haven't found any clues in the manual or the FAQs. Is it me? -r ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 14:58 [Caml-list] Conditional Modules Ross Duncan @ 2004-08-04 16:02 ` Richard Jones 2004-08-04 16:29 ` Michel Mauny 2004-08-04 16:45 ` John Prevost 2004-08-04 17:23 ` henri dubois-ferriere 2004-08-04 17:24 ` james woodyatt 2 siblings, 2 replies; 13+ messages in thread From: Richard Jones @ 2004-08-04 16:02 UTC (permalink / raw) Cc: caml-list On Wed, Aug 04, 2004 at 03:58:50PM +0100, Ross Duncan wrote: > Forgive me for asking what might be an easy question, I am just a > beginner with Ocaml. I want to do something like this: > > module M = if arg then M1 else M2 > module A = F (M) > (* define rest of program using fields of A *) > > The idea being that arg will come from e.g. the command line, and > modules M1, M2 and functor F are defined elsewhere. I suspect that the only way to do it would be with pa_macro.cmo (part of Camlp4). This means it would be done at compile time, which is probably not what you wanted. http://caml.inria.fr/camlp4/manual/manual002.html#toc1 (BTW: What is the difference between pa_macro and pa_ifdef? I have both on my system, and they appear to do much the same thing.) Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment http://www.winwinsales.co.uk/ - CRM improvement consultancy ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 16:02 ` Richard Jones @ 2004-08-04 16:29 ` Michel Mauny 2004-08-04 16:45 ` John Prevost 1 sibling, 0 replies; 13+ messages in thread From: Michel Mauny @ 2004-08-04 16:29 UTC (permalink / raw) To: Richard Jones; +Cc: caml-list Richard Jones wrote/écrivait (Wed, Aug 04, 2004 at 05:02:47PM +0100): > (BTW: What is the difference between pa_macro and pa_ifdef? I have > both on my system, and they appear to do much the same thing.) pa_macro is more general than pa_ifdef, and pa_ifdef is deprecated since OCaml 3.07. -- Michel Mauny ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 16:02 ` Richard Jones 2004-08-04 16:29 ` Michel Mauny @ 2004-08-04 16:45 ` John Prevost 2004-08-04 17:22 ` Shivkumar Chandrasekaran 2004-08-05 11:23 ` Ross Duncan 1 sibling, 2 replies; 13+ messages in thread From: John Prevost @ 2004-08-04 16:45 UTC (permalink / raw) To: caml-list If you're choosing between options at runtime, you might consider thinking about a plugin architecture instead. Modules are pretty much all set at link time. Here's a simple example of the strategy: module M = struct exception No_plugin type entry = { reg_f : int -> int } let current_entry : entry option = ref None let register e = current_entry := Some e let get_entry () = match !current_entry with | None -> raise No_plugin | Some e -> e let f x = (get_entry ()).f x end module M1 = struct let f x = x + 1 let m1_entry = { M.reg_f = f } let _ = M.register m1_entry end This model puts more constraints on types than using modules would, but does have a variety of different ways to be useful. For example, M1 could instead of registering automatically wait until told, or M could keep a list of registered plugins and take the first one that "works" for an input, etc. And finally, you may also be able to do things differently using functors--one of which you seem to be using in your example. Here's an example of my idea here: Original: module M = if arg then M1 else M2 type t = M.t let f = M.f let g = M.g ... can instead be written: module X (M : M_T) : R_T with type t = (* something *) = struct (* definitions involving M *) end module X1 = X(M1) module X2 = X(M2) type t = X1.t let f = if arg then X1.f else X2.f let g = if arg then X1.g else X2.g This approach is a little verbose, but should work reasonably well. Again, your constraint here is that X1 and X2 will have to have identical types, not just similar types. (And that's the real reason that you can't do conditionals to choose one of several modules: you can't do conditionals at runtime on types!) John. ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 16:45 ` John Prevost @ 2004-08-04 17:22 ` Shivkumar Chandrasekaran 2004-08-05 11:23 ` Ross Duncan 1 sibling, 0 replies; 13+ messages in thread From: Shivkumar Chandrasekaran @ 2004-08-04 17:22 UTC (permalink / raw) To: caml-list I find the following paradigm useful sometimes: module Params = struct let param1 = ... (* from command line args *) let param2 = ... end module M1 = F1 (Params, ...) (* specialize modules to command line args *) module M2 = F2 (Params, ...) module M3 ... (* call correct main routine *) if predicate1 args then M1.main () else if predicate2 args then M2.main () else if ... ... In other words, fold the whole main function into the functors. Then only the main routine in each module must return same type and the individual modules themselves are free of each other. Of course you can do this for functions other than main too. --shiv-- John Prevost wrote: >If you're choosing between options at runtime, you might consider >thinking about a plugin architecture instead. Modules are pretty much >all set at link time. > >Here's a simple example of the strategy: > >module M = struct > exception No_plugin > type entry = { reg_f : int -> int } > let current_entry : entry option = ref None > let register e = current_entry := Some e > let get_entry () = match !current_entry with > | None -> raise No_plugin > | Some e -> e > let f x = (get_entry ()).f x >end > >module M1 = struct > let f x = x + 1 > let m1_entry = { M.reg_f = f } > let _ = M.register m1_entry >end > >This model puts more constraints on types than using modules would, >but does have a variety of different ways to be useful. For example, >M1 could instead of registering automatically wait until told, or M >could keep a list of registered plugins and take the first one that >"works" for an input, etc. > >And finally, you may also be able to do things differently using >functors--one of which you seem to be using in your example. Here's >an example of my idea here: > >Original: > >module M = if arg then M1 else M2 > >type t = M.t > >let f = M.f >let g = M.g >... > >can instead be written: > >module X (M : M_T) : R_T with type t = (* something *) = struct > (* definitions involving M *) >end > >module X1 = X(M1) >module X2 = X(M2) > >type t = X1.t > >let f = if arg then X1.f else X2.f >let g = if arg then X1.g else X2.g > >This approach is a little verbose, but should work reasonably well. >Again, your constraint here is that X1 and X2 will have to have >identical types, not just similar types. (And that's the real reason >that you can't do conditionals to choose one of several modules: you >can't do conditionals at runtime on types!) > >John. > >------------------- >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 > ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 16:45 ` John Prevost 2004-08-04 17:22 ` Shivkumar Chandrasekaran @ 2004-08-05 11:23 ` Ross Duncan 2004-08-05 12:34 ` Alain Frisch 2004-08-05 15:10 ` Jean-Baptiste Rouquier 1 sibling, 2 replies; 13+ messages in thread From: Ross Duncan @ 2004-08-05 11:23 UTC (permalink / raw) To: caml-list Thanks to everyone who replied to my plea for help. Unfortunately I don't believe that any of the very good suggestions I received will solve my problem. As John Prevost said: > (And that's the real reason > that you can't do conditionals to choose one of several modules: you > can't do conditionals at runtime on types!) If I had specified my problem a little more carefully I might have said 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. So I guess my request for help should now become a feature request for the language! Is this at all compatible with static typing? Thanks again for all the suggestions. Ross ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-05 11:23 ` Ross Duncan @ 2004-08-05 12:34 ` Alain Frisch 2004-08-05 15:10 ` Jean-Baptiste Rouquier 1 sibling, 0 replies; 13+ messages in thread From: Alain Frisch @ 2004-08-05 12:34 UTC (permalink / raw) To: Ross Duncan; +Cc: Caml list On Thu, 5 Aug 2004, Ross Duncan wrote: > So I guess my request for help should now become a feature request for > the language! Is this at all compatible with static typing? Yes, it is. One issue is to specify the type of the result; one would like to compute the least upper bound of the two module types. The simple-minded patch below chooses a simpler method: it takes the type of the first branch as the type for the result (the second branch must be compatible with this type). But there is no reason to stop with this if-then-else construction; one could for instance import the match and the let-in construction from the core language to the module language. A nice solution would be to make the core language/type system and the module language/type system mutually recursive. One simple solution has been proposed in: Claudio V. Russo. First-Class Structures for Standard ML. http://www.dcs.ed.ac.uk/home/cvr/ One would have a "pack" operation that takes a module value and turns it into a core value (packed module), an "unpack" operation that takes a packed module and turns it into a module value (with a given module type). The if-then-else could be encoded as: module M = unpack (if e then pack M1 else pack M2 : S) but you could also do: let f b = let module M = unpack (if e then pack M1 else pack M2 : S) in ... I implemented some time ago such a patch for OCaml (actually, there was only the "let module M = unpack (...)" construction and not the unpack in the module language): http://www.eleves.ens.fr/home/frisch/soft#patches -- Alain diff -Naur ocaml/bytecomp/translmod.ml ocaml_if/bytecomp/translmod.ml --- ocaml/bytecomp/translmod.ml 2004-06-12 10:55:45.000000000 +0200 +++ ocaml_if/bytecomp/translmod.ml 2004-08-05 14:04:22.000000000 +0200 @@ -268,6 +268,10 @@ [transl_module ccarg None arg])) | Tmod_constraint(arg, mty, ccarg) -> transl_module (compose_coercions cc ccarg) rootpath arg + | Tmod_ifthenelse(e,y,n,c) -> + Lifthenelse(transl_exp e, + transl_module cc rootpath y, + transl_module (compose_coercions cc c) rootpath n) and transl_structure fields cc rootpath = function [] -> diff -Naur ocaml/parsing/parser.mly ocaml_if/parsing/parser.mly --- ocaml/parsing/parser.mly 2004-05-19 14:15:19.000000000 +0200 +++ ocaml_if/parsing/parser.mly 2004-08-05 14:06:28.000000000 +0200 @@ -420,6 +420,8 @@ { unclosed "(" 2 ")" 4 } | LPAREN module_expr COLON module_type RPAREN { mkmod(Pmod_constraint($2, $4)) } + | IF expr THEN module_expr ELSE module_expr + { mkmod(Pmod_ifthenelse($2,$4,$6)) } | LPAREN module_expr COLON module_type error { unclosed "(" 1 ")" 5 } | LPAREN module_expr RPAREN diff -Naur ocaml/parsing/parsetree.mli ocaml_if/parsing/parsetree.mli --- ocaml/parsing/parsetree.mli 2003-11-25 09:46:45.000000000 +0100 +++ ocaml_if/parsing/parsetree.mli 2004-08-05 13:51:26.000000000 +0200 @@ -236,6 +236,7 @@ | Pmod_functor of string * module_type * module_expr | Pmod_apply of module_expr * module_expr | Pmod_constraint of module_expr * module_type + | Pmod_ifthenelse of expression * module_expr * module_expr and structure = structure_item list diff -Naur ocaml/parsing/printast.ml ocaml_if/parsing/printast.ml --- ocaml/parsing/printast.ml 2003-11-25 09:46:45.000000000 +0100 +++ ocaml_if/parsing/printast.ml 2004-08-05 13:52:31.000000000 +0200 @@ -545,6 +545,11 @@ line i ppf "Pmod_constraint\n"; module_expr i ppf me; module_type i ppf mt; + | Pmod_ifthenelse (e,y,n) -> + line i ppf "Pmod_ifthenelse\n"; + expression i ppf e; + module_expr i ppf y; + module_expr i ppf n and structure i ppf x = list i structure_item ppf x diff -Naur ocaml/typing/typedtree.ml ocaml_if/typing/typedtree.ml --- ocaml/typing/typedtree.ml 2003-11-25 10:20:43.000000000 +0100 +++ ocaml_if/typing/typedtree.ml 2004-08-05 14:01:11.000000000 +0200 @@ -126,6 +126,7 @@ | Tmod_functor of Ident.t * module_type * module_expr | Tmod_apply of module_expr * module_expr * module_coercion | Tmod_constraint of module_expr * module_type * module_coercion + | Tmod_ifthenelse of expression * module_expr * module_expr * module_coercion and structure = structure_item list diff -Naur ocaml/typing/typedtree.mli ocaml_if/typing/typedtree.mli --- ocaml/typing/typedtree.mli 2003-11-25 10:20:43.000000000 +0100 +++ ocaml_if/typing/typedtree.mli 2004-08-05 14:01:10.000000000 +0200 @@ -127,6 +127,7 @@ | Tmod_functor of Ident.t * module_type * module_expr | Tmod_apply of module_expr * module_expr * module_coercion | Tmod_constraint of module_expr * module_type * module_coercion + | Tmod_ifthenelse of expression * module_expr * module_expr * module_coercion and structure = structure_item list diff -Naur ocaml/typing/typemod.ml ocaml_if/typing/typemod.ml --- ocaml/typing/typemod.ml 2004-06-13 14:48:01.000000000 +0200 +++ ocaml_if/typing/typemod.ml 2004-08-05 14:00:17.000000000 +0200 @@ -514,6 +514,20 @@ mod_type = mty; mod_env = env; mod_loc = smod.pmod_loc } + | Pmod_ifthenelse(se,sy,sn) -> + let e = Typecore.type_expression env se in + let y = type_module anchor env sy in + let mty = y.mod_type in + let n = type_module anchor env sn in + let coercion = + try + Includemod.modtypes env n.mod_type mty + with Includemod.Error msg -> + raise(Error(sn.pmod_loc, Not_included msg)) in + rm { mod_desc = Tmod_ifthenelse(e,y,n,coercion); + mod_type = mty; + mod_env = env; + mod_loc = smod.pmod_loc } and type_structure anchor env sstr = let type_names = ref StringSet.empty ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-05 11:23 ` Ross Duncan 2004-08-05 12:34 ` Alain Frisch @ 2004-08-05 15:10 ` Jean-Baptiste Rouquier 2004-08-05 15:54 ` Christophe Raffalli 1 sibling, 1 reply; 13+ messages in thread From: Jean-Baptiste Rouquier @ 2004-08-05 15:10 UTC (permalink / raw) To: Ross Duncan; +Cc: caml-list 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-05 15:10 ` Jean-Baptiste Rouquier @ 2004-08-05 15:54 ` Christophe Raffalli 2004-08-06 7:53 ` Alain Frisch 0 siblings, 1 reply; 13+ messages in thread From: Christophe Raffalli @ 2004-08-05 15:54 UTC (permalink / raw) Cc: caml-list Is there plan to have first class modules in OCaml (in other word merge record/structure and function/functor) ? If I understood well (I did not look myself) MoscowML has this. This would solve many problems ... -- Christophe Raffalli Université de Savoie Batiment Le Chablais, bureau 21 73376 Le Bourget-du-Lac Cedex tél: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI --------------------------------------------- IMPORTANT: this mail is signed using PGP/MIME At least Enigmail/Mozilla, mutt or evolution can check this signature --------------------------------------------- ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-05 15:54 ` Christophe Raffalli @ 2004-08-06 7:53 ` Alain Frisch 0 siblings, 0 replies; 13+ messages in thread From: Alain Frisch @ 2004-08-06 7:53 UTC (permalink / raw) To: Christophe Raffalli; +Cc: caml-list On Thu, 5 Aug 2004, Christophe Raffalli wrote: > Is there plan to have first class modules in OCaml (in other word merge > record/structure and function/functor) ? If I understood well (I did not > look myself) MoscowML has this. AFAIK, MoscowML had packaged modules, which keeps the two levels (core / module) stratified, but allows a module to be packaged in a value. In this system, you can write functions from packaged modules to packaged modules, but you cannot express type dependencies between the input and the output type (equivalently: there is no polymorphism on types within packaged signatures). So, there is still a need for a separate notion of functors. -- Alain ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 14:58 [Caml-list] Conditional Modules Ross Duncan 2004-08-04 16:02 ` Richard Jones @ 2004-08-04 17:23 ` henri dubois-ferriere 2004-08-04 17:24 ` james woodyatt 2 siblings, 0 replies; 13+ messages in thread From: henri dubois-ferriere @ 2004-08-04 17:23 UTC (permalink / raw) To: Ross Duncan; +Cc: caml-list this isn't possible, because modules are not first class values. there was a thread on this with some examples of how to get around it: http://caml.inria.fr/archives/200209/msg00317.html henri On Wed, 4 Aug 2004 15:58:50 +0100, Ross Duncan <ross.duncan@comlab.ox.ac.uk> wrote: > Forgive me for asking what might be an easy question, I am just a > beginner with Ocaml. I want to do something like this: > > module M = if arg then M1 else M2 > module A = F (M) > (* define rest of program using fields of A *) > > The idea being that arg will come from e.g. the command line, and > modules M1, M2 and functor F are defined elsewhere. > > Of course "module M = if ... " is a syntax error. My question is: > how to achieve this behaviour (and generalisations of it) in ocaml? > > It seems that this is an obvious thing to want to do but I haven't > found any clues in the manual or the FAQs. Is it me? > > -r > > ------------------- > 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 > ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 14:58 [Caml-list] Conditional Modules Ross Duncan 2004-08-04 16:02 ` Richard Jones 2004-08-04 17:23 ` henri dubois-ferriere @ 2004-08-04 17:24 ` james woodyatt 2004-08-04 18:01 ` John Prevost 2 siblings, 1 reply; 13+ messages in thread From: james woodyatt @ 2004-08-04 17:24 UTC (permalink / raw) To: Ross Duncan; +Cc: caml-list On 04 Aug 2004, at 07:58, Ross Duncan wrote: > > Forgive me for asking what might be an easy question, I am just a > beginner with Ocaml. I want to do something like this: > > module M = if arg then M1 else M2 > module A = F (M) > (* define rest of program using fields of A *) > > The idea being that arg will come from e.g. the command line, and > modules M1, M2 and functor F are defined elsewhere. > > Of course "module M = if ... " is a syntax error. My question is: > how to achieve this behaviour (and generalisations of it) in ocaml? > > It seems that this is an obvious thing to want to do but I haven't > found any clues in the manual or the FAQs. Is it me? This is one of those cases where using classes and objects is the right way to go. class type c = object ... end class c1 : c class c2 : c module M: sig val c: c end module A(sig val c: c end): sig ... end ― ∴ ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] Conditional Modules 2004-08-04 17:24 ` james woodyatt @ 2004-08-04 18:01 ` John Prevost 0 siblings, 0 replies; 13+ messages in thread From: John Prevost @ 2004-08-04 18:01 UTC (permalink / raw) To: caml-list On Wed, 4 Aug 2004 10:24:30 -0700, james woodyatt <jhw@wetware.com> wrote: > This is one of those cases where using classes and objects is the right > way to go. > > class type c = object ... end > class c1 : c > class c2 : c > > module M: sig val c: c end > module A(sig val c: c end): sig ... end Maybe, maybe not. This creates a different set of issues--like not being able to define a type as a member of a class. It all depends on what you want to do. John. ------------------- 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2004-08-06 7:53 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-08-04 14:58 [Caml-list] Conditional Modules Ross Duncan 2004-08-04 16:02 ` Richard Jones 2004-08-04 16:29 ` Michel Mauny 2004-08-04 16:45 ` John Prevost 2004-08-04 17:22 ` Shivkumar Chandrasekaran 2004-08-05 11:23 ` Ross Duncan 2004-08-05 12:34 ` Alain Frisch 2004-08-05 15:10 ` Jean-Baptiste Rouquier 2004-08-05 15:54 ` Christophe Raffalli 2004-08-06 7:53 ` Alain Frisch 2004-08-04 17:23 ` henri dubois-ferriere 2004-08-04 17:24 ` james woodyatt 2004-08-04 18:01 ` John Prevost
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox