caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Chris King" <colanderman@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] module types and constraints in several layers
Date: Thu, 15 Mar 2007 08:25:08 -0500	[thread overview]
Message-ID: <875c7e070703150625r2fe44739r86755099a2bd2594@mail.gmail.com> (raw)
In-Reply-To: <20070315101236.GB3236@pc6197-c703.uibk.ac.at>

On 3/15/07, Christian Sternagel <christian.sternagel@uibk.ac.at> wrote:
> but I was not able to tell the compiler (correctly) that after
> building module E ist should be the case that for example
> E.E1 = D.D1 = B.B1 = A = E4.D.D1 = E4.D.D2.B1 = ...
>
> Is there a convenient way to make such a structure of modules?
> And if yes, how ist it done?

What's happening is that, when you specify the type of the results of
B.Make and D.Make, O'Caml throws away the info about how they were
created: since the type signatures B.T and D.T simply say "these
modules have some submodules" but don't say where the submodules come
from, that info becomes hidden (as it should be).  However you can
explicitly instruct the compiler not to hide this info:

module Make (A : A.T) : B.T with module B1 = A = struct
 ...
 module B1 = A
 ...
end

This just says "give the resulting module the signature B.T, but
retain the info that module B1 equals A".  Similarly:

module Make (B : B.T) (C : C.T) : D.T
    with module D1 = B.B1 and module D2 = B
    = struct
 ...
 module D1 = B.B1
 module D2 = B
 module D3 = C
 ...
end

You don't need to do this with E.Make since its signature is left intact.

You can do this with individual types too, see section 6.10 of the manual.


  reply	other threads:[~2007-03-15 13:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-15 10:12 Christian Sternagel
2007-03-15 13:25 ` Chris King [this message]
2007-03-15 14:21   ` [Caml-list] " Christian Sternagel
2007-03-15 14:48     ` Chris King
2007-03-15 15:38       ` Christian Sternagel

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=875c7e070703150625r2fe44739r86755099a2bd2594@mail.gmail.com \
    --to=colanderman@gmail.com \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).