Version française
Home     About     Download     Resources     Contact us    
Browse thread
Module abbreviation
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ashish Agarwal <agarwal1975@g...>
Subject: Re: [Caml-list] Module abbreviation
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. Please double check your
example. It cannot be working as you describe.

On Tue, Dec 15, 2009 at 11:39 AM, Romain Bardou <romain@bardou.fr> wrote:

> Hello, dear Caml-list,
>
> I have a file ast.mli. It has no .ml implementation as it contains only
> type definitions.
>
> I have a file toto.ml, which contains simply:
>
> module A = Ast
>
> So I only use it as an abbreviation, to write A.t instead of Ast.t for
> instance.
>
> However, at link-time, the following error occurs:
>
> File "_none_", line 1, characters 0-1:
> Error: Error while linking toto.cmo:
> Reference to undefined global `Ast'
>
> I found a workaround, which is to change ast.mli to put all type
> definitions in a signature, such as:
>
> module type Sig =
> sig
>  type t = ...
>  ...
> end
>
> And then, in toto.ml:
>
> module type A =
> sig
>  include Ast.Sig
> end
>
> Is there any better way to write such a module abbreviation, without
> changing ast.mli? And, of course, without copying or renaming ast.mli
> into ast.ml.
>
> By the way, this is yet another evidence for the need of a construction
> "sig of" which would take a module (with or without implementation) and
> return its signature.
>
> Thanks,
>
> --
> Romain Bardou
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>