Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: pbrisset@eis.enac.dgac.fr
To: caml-list@margaux.inria.fr
Subject: Re: One more question about the module system
Date: Fri, 29 Mar 1996 15:10:46 +0100	[thread overview]
Message-ID: <199603291410.PAA02850@concorde.inria.fr> (raw)


...
> (* m1.ml *)
>         module Make(L: MTYPE_L)(Some_M2: MTYPE_M2) = struct
>           open L
>           open Some_M2
>           ...
>         end
> (* m.ml *)
>         module Make(L: MTYPE_L)(Some_M1: MTYPE_M1) = struct
>           open L
>           open Some_M1
>           ...
>         end
> 
> (You will probably need to express sharing constraints between type
> components of the parameters. Express them with "with type" or
> "with module", e.g.
>         module Make(L: MTYPE_L)(Some_M2: MTYPE_M2 with type t = L.t) ...
> )
> 
> Then do all the functor applications in a "main" file:
> 
>         module L = L1 (* or L2 *)
>         module M2 = M2.Make(L)
>         module M1 = M1.Make(L)(M2)
>         module M = M.Make(L)(M1)
> 
> The advantage of this approach is that you can also provide
> "hand-made" M1 or M2 modules (not produced by application of M1.Make
> or M2.Make), so you get more flexibility. The disadvantage is
> increased verbosity and number of declarations needed.
> 
> - Xavier Leroy

 I eventually found the same solution. Because I wanted a single "big"
module, I wrote:

	(* m.ml *)
	module Make(L: SIG_L) = struct
	  module M2 = M2.Make(L)
	  open M2
	  module M1 = M1.Make(L, M2)
	  open M1
	  ...

 I also checked that runtime efficiency is not modified by all these
functorizations.

--Pascal





             reply	other threads:[~1996-04-01 12:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-29 14:10 pbrisset [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-03-25 17:22 pbrisset
1996-03-28 14:16 ` Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199603291410.PAA02850@concorde.inria.fr \
    --to=pbrisset@eis.enac.dgac.fr \
    --cc=caml-list@margaux.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox