caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David Allsopp" <dra-news@metastack.com>
To: "'Ashish Agarwal'" <agarwal1975@gmail.com>,
	"'Romain Bardou'" <romain@bardou.fr>
Cc: "'caml-list'" <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] Module abbreviation
Date: Wed, 16 Dec 2009 00:28:09 +0100	[thread overview]
Message-ID: <017401ca7dde$448c7d70$cda57850$@allsopp@metastack.com> (raw)
In-Reply-To: <d8be5ae20912150856l59d0fbeeyfda2628cfbfe5b96@mail.gmail.com>

Ashish Agarwal wrote:
> If you only have a file ast.mli, you should not be able to write Ast.Sig
because you do not have a module named Ast.

This isn't true - the include statement works at a type system level
(because you're dealing with a signature) and therefore only a .cmi file is
required. It does not generate any work for the linker so a module called
Ast is not actually needed when linking.

> Please double check your example. It cannot be working as you describe.

I'm afraid you should have checked - the example given compiles (try ocamlc
-o foo ast.mli toto.ml with suitable substitutions for the "..."s)

Romain Bardou wrote:

> I have a file ast.mli. It has no .ml implementation as it contains only
> type definitions.

This is fine

> I have a file toto.ml, which contains simply:
> 
> module A = Ast

But as this involves a linker instruction you need an actual module - hence
the error you're seeing. I guess you could argue that the module statement
could check to see if Ast only contains type definitions and relax the need
for an actual module but in the general case Ast could contain values and so
you need a module to link against.

> I found a workaround, which is to change ast.mli to put all type
> definitions in a signature, such as:

This workaround works because you take the whole thing back to the type
system so module implementations are not required by the linker.


David


  reply	other threads:[~2009-12-15 23:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-15 16:39 Romain Bardou
2009-12-15 16:56 ` [Caml-list] " Ashish Agarwal
2009-12-15 23:28   ` David Allsopp [this message]
     [not found]   ` <-5655904566200171061@unknownmsgid>
2009-12-16  3:17     ` Ashish Agarwal
2009-12-15 17:01 ` Basile STARYNKEVITCH
2009-12-17 11:35   ` Romain Bardou
2009-12-18  6:55     ` Basile STARYNKEVITCH
2009-12-18 12:06       ` Romain Bardou

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='017401ca7dde$448c7d70$cda57850$@allsopp@metastack.com' \
    --to=dra-news@metastack.com \
    --cc=agarwal1975@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=romain@bardou.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).