English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
type t = ()
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-06-10 (12:56)
From: Wolfgang Lux <wlux@u...>
Subject: Re: [Caml-list] Re: type t = ()
Vincenzo Ciancia wrote:

> Richard Jones wrote:
>> # type dummy = ();;
>> type dummy = ()
>> # let () = Printf.printf "hello";;
>> This expression has type unit but is here used with type dummy
> It seems that the compiler accepted "()" as a type constructor, so now 
> every
> instance of "()" is the only constructor of type "dummy" e.g.

Sorry for nitpicking, but in this case () is a *data* constructor.
I guess, Rich would have been more happy if OCaml did recognize ()
as a type constructor in this example.

However, I guess one cannot do much about this in OCaml since () is
a legitimate data constructor name. The problem really is that the
(O)Caml designers chose to overload the type keyword for defining
algebraic data types as well as type abbreviations. Compare with SML
and Haskell where different keywords are used.