Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Sumtypes of records
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ville-Pertti Keinonen <will@e...>
Subject: Re: [Caml-list] Sumtypes of records

> Why can't constructors of sumtypes take nameless records? (Warning 
> stupid example follows)
> type plop = Foo | Bar {age : int};;


Probably because it wouldn't make much sense.  Either the only way you 
could access age in the above is by matching Bar { age = x }, which is 
not very useful (you might as well have Bar of int, or a tuple for 
multiple fields), or the record type needs to have a name so that x in 
the pattern Bar x has some printable type.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: