From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA28793 for caml-red; Tue, 3 Oct 2000 21:06:16 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA21934 for ; Tue, 3 Oct 2000 11:53:18 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e939r5X09661; Tue, 3 Oct 2000 11:53:05 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA01372; Tue, 3 Oct 2000 11:53:04 +0200 (MET DST) Message-ID: <20001003115304.56543@pauillac.inria.fr> Date: Tue, 3 Oct 2000 11:53:04 +0200 From: Xavier Leroy To: Julian Assange , caml-list@inria.fr Subject: Re: list of objects References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: ; from Julian Assange on Tue, Oct 03, 2000 at 03:38:59AM +1100 Sender: weis@pauillac.inria.fr Your approach looks reasonable. As for your question: > let sig_list = [new plain; new simple] > On compilation, this produces: > The type of this expression, '_a Sigs.plain list, > contains type variables that cannot be generalized > However sending the exact same code to the top level, > produces: > val sig_list : '_a Sigs.plain list = [; ] > Works just fine! What gives? The '_a is a non-generalized type variable, i.e. an unknown type that will be determined later at first use. (See the FAQ http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html for more detailed explanations.) For separately-compiled units, the notion of "first use" is unclear, since the unit can be referenced by several other separately-compiled units, which could each instantiate the unknown type in different ways. So, to keep things simple, the compiler requires that no non-generalized type variables remain in the types inferred for definitions of a compilation unit. Thus, you need to put either a .mli file giving the type you want for sig_list, or a type constraint on the definition of sig_list: let sig_list = ([new plain; new simple] : t Sigs.plain list) with the type you want for "t". Hope this helps, - Xavier Leroy