Have anonymous variants ever been proposed for OCaml?

Often I’ll be defining a record type like:

type adt = A of int | B of string
type t = {
  adt: adt; 
  uid: int;
} 

where I have to define some entire separate type to hold the variant. The type is never constructed by itself and it would be more convenient to just be able to write:

type t = {
  adt: A of int | B of string
  uid: int;
} 

Has this sort of anonymous variant structure ever been proposed for OCaml?

OCaml - Polymorphic variants ?

2 Likes

Since the polymorphic variants have almost all the benefits of anonymous variants without the shortcomings, I’m guessing no one seriously considered them. On the other hand, anonymous records have benefits that are missing from the pre-existing alternatives (objects).

2 Likes