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 RAA01297 for caml-redistribution; Thu, 18 Feb 1999 17:48:39 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA30783 for ; Thu, 18 Feb 1999 15:03:36 +0100 (MET) Received: from mail4.microsoft.com (mail4.microsoft.com [131.107.3.122]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id PAA04775; Thu, 18 Feb 1999 15:03:33 +0100 (MET) Received: by mail4.microsoft.com with Internet Mail Service (5.5.2524.0) id ; Thu, 18 Feb 1999 06:03:34 -0800 Message-ID: <39ADCF833E74D111A2D700805F1951EF0F00B9CB@RED-MSG-06> From: Don Syme To: "'Xavier Leroy'" , Christopher Jeris , caml-list@inria.fr Subject: RE: anonymous record types in variants Date: Thu, 18 Feb 1999 06:03:32 -0800 X-Mailer: Internet Mail Service (5.5.2524.0) Sender: weis > > type foo_one = {one: int} > > type foo_two = {two: string} > > type foo = One of foo_one | Two of foo_two > > > > But, just out of curiosity, is there a quick explanation of > why it is this > > way? > > Basically, because "{one : int}" is not a type expression, and the > argument of a constructor must be a type expression. > > The reason why "{one : int}" is not a type expression but must be > declared and bound to a type name have to do with type inference > and the existence of principal types. If you allow record types in > type expressions (as in SML), some functions have no principal type, > such as fun x -> x.l. I think all we're thinking of is a mechanism so the user doesn't have to write nonsense type names such as foo_one and foo_two as in the above example. Within a (mutually recursive) type declaration, shouldn't it be feasible to use tuples, records and variants freely, as long as all the names of all the fields and constructors are used at only one place in the declaration? Of course you would always need named types for recursive type constructors. Cheers & thanks, Don ------------------------------------------------------------------------ At the lab: At home: Microsoft Research Cambridge 11 John St St George House CB1 1DT Cambridge, CB2 3NH, UK Ph: +44 (0) 1223 744797 Ph: +44 (0) 1223 722244 http://research.microsoft.com/users/dsyme email: dsyme@microsoft.com "You've been chosen as an extra in the movie adaptation of the sequel to your life" -- Pavement, Shady Lane ------------------------------------------------------------------------