From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 29CB5BC0A for ; Fri, 15 Jun 2007 16:40:03 +0200 (CEST) Received: from [128.93.11.95] (estephe.inria.fr [128.93.11.95]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5FEdsiZ003963; Fri, 15 Jun 2007 16:39:54 +0200 Message-ID: <4672A4BA.2020607@inria.fr> Date: Fri, 15 Jun 2007 16:39:54 +0200 From: Xavier Leroy User-Agent: Thunderbird 1.5.0.7 (X11/20060915) MIME-Version: 1.0 To: Pietro Abate , ocaml ml Subject: Re: [Caml-list] type_declaration in env.ml References: <20070615124119.GD20124@pulp.rsise.anu.edu.au> In-Reply-To: <20070615124119.GD20124@pulp.rsise.anu.edu.au> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4672A4BA.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 params:01 expr:01 arity:01 expr:01 bool:01 bool:01 mutable:01 params:01 arity:01 desc:01 tvar:01 desc:01 tvar:01 wrote:01 Pietro Abate wrote: > hi all, > I'm trying to understand this data structure in env.ml in the ocaml src > files. > > type type_declaration = > { type_params: type_expr list; > type_arity: int; > type_kind: type_kind; > type_manifest: type_expr option; > type_variance: (bool * bool * bool) list } > > and type_kind = > Type_abstract > | Type_variant of (string * type_expr list) list * private_flag > | Type_record of (string * mutable_flag * type_expr) list > * record_representation * private_flag > > > If I've a type like : > type t = A of int | B of float > > I'll get > > type_params = [] > type_arity = 0 > type_kind = Type_variant ( > [ "A", [ { desc = Tvar ; level = ?? ; id = ?? }] ; > "B", [ { desc = Tvar ; level = ?? ; id = ?? }] ] , false ) > type_manifest = ?? > type_variance = [] > > correct ? Yes, with type_manifest = None. > what if I have just > type t = int ? As above, except type_kind = Type_abstract type_manifest = Some And before you ask, type t = M.t = A of int | B of float would be type_kind = Type_variant ( ["A", ... ; "B", ....], false) type_manifest = Some > where I store the type identifier "t" in both cases ? The typing environment (type Env.t) maps type identifiers such as "t" to type declarations such as the above. > Can anybody explain me the semantic of these fields ? I can guess some, > but I'm not very confident... Section 6.8.1 of the reference manual could help you understand the interaction between the "type_kind" and "type_manifest" fields, and in particular the reason why these are two separate fields. Hope this helps, - Xavier Leroy