Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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.

Regards
Wolfgang