RE: anonymous record types in variants

From: Don Syme (
Date: Thu Feb 18 1999 - 15:03:32 MET

From: Don Syme <>
To: "'Xavier Leroy'" <>,
Subject: RE: anonymous record types in variants
Date: Thu, 18 Feb 1999 06:03:32 -0800

> > 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
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
of all the fields and constructors are used at only one place in the
Of course you would always need named types for recursive type constructors.

Cheers & thanks,

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
   "You've been chosen as an extra in the movie
        adaptation of the sequel to your life" -- Pavement, Shady Lane

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:19 MET