From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 4FD21BB81 for ; Sat, 12 Nov 2005 00:57:13 +0100 (CET) Received: from ptb-relay04.plus.net (ptb-relay02.plus.net [212.159.14.213]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jABNvC54006043 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sat, 12 Nov 2005 00:57:13 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay04.plus.net with esmtp (Exim) id 1Eailc-00066d-An for caml-list@yquem.inria.fr; Fri, 11 Nov 2005 23:57:12 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] strange behavior with record type definition Date: Fri, 11 Nov 2005 23:52:39 +0000 User-Agent: KMail/1.8.2 References: <43752259.80800@aist.enst.fr> In-Reply-To: <43752259.80800@aist.enst.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200511112352.39853.jon@ffconsultancy.com> X-Miltered: at concorde with ID 43752FD8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 compiler:01 ocaml:01 frog:98 wrote:01 define:01 int:01 int:01 modules:01 defined:01 caml:02 match:02 match:02 objective:02 labels:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Friday 11 November 2005 22:59, Florent wrote: > Hi, I have defined two distinct record's types with a field's name in > common. But when I try to define a function that uses the first of the > types, the compiler gives me a type error. > How can I use my first type in a function ?? > > This is what I did: > > # type t0 = { i : int ; s : string };; > type t0 = { i : int; s : string; } > # type t1 = { i : int ; f : float };; > type t1 = { i : int; f : float; } > # let f (x:t0) = match x with {i= a; s= b} -> b;; > Characters 28-40: > let f (x:t0) = match x with {i= a; s= b} -> b;; > ^^^^^^^^^^^^ > The record field label s belongs to the type t0 > but is here mixed with labels of type t1 Either use different field names, e.g.: type t0 = { i0 : int ; s0 : string } type t1 = { i1 : int ; f1 : float } or put them in separate modules. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists