caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ashish Agarwal <agarwal1975@gmail.com>
To: David Allsopp <dra-news@metastack.com>
Cc: Romain Bardou <romain@bardou.fr>, caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Module abbreviation
Date: Tue, 15 Dec 2009 22:17:12 -0500	[thread overview]
Message-ID: <d8be5ae20912151917i4ce28231hab95219e4ee2647f@mail.gmail.com> (raw)
In-Reply-To: <-5655904566200171061@unknownmsgid>

[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]

> the example given compiles

Surprising! I see your point about the types working out, but this also
requires the additional assumption that the module type defined by ast.mli
will be ascribed specifically to a module named Ast. I suppose this is
consistent with how ocaml associates file names with modules so it works
out.


On Tue, Dec 15, 2009 at 6:28 PM, David Allsopp <dra-news@metastack.com>wrote:

> 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
>
>

[-- Attachment #2: Type: text/html, Size: 2594 bytes --]

  parent reply	other threads:[~2009-12-16  3:17 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
     [not found]   ` <-5655904566200171061@unknownmsgid>
2009-12-16  3:17     ` Ashish Agarwal [this message]
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=d8be5ae20912151917i4ce28231hab95219e4ee2647f@mail.gmail.com \
    --to=agarwal1975@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=dra-news@metastack.com \
    --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).