English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2009-12-15 (16:39)
From: Romain Bardou <romain@b...>
Subject: Module abbreviation
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

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 =
  type t = ...

And then, in toto.ml:

module type A =
  include Ast.Sig

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.


Romain Bardou