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
Void type?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-07-28 (08:22)
From: rossberg@p...
Subject: Re: [Caml-list] Re: Void type?
Chung-chieh Shan wrote:
> Stefan Monnier <> wrote in article
> <> in
> gmane.comp.lang.caml.inria:
>> Is there a void type in OCaml (i.e. a type which has no values), or a
>> way to
>> simulate it?
> type void = Void of void

Dont't forget OCaml's let-rec:

  let rec v = Void v

works like a charm.

Sébastian Hinderer wrote:
> What about
> type void = { v : void };;

Same here:

  let rec v = {v = v}

Since there are no empty polymorphic variants either (there used to be in
earlier versions, IIRC), the only solution is:

Chris Kings wrote:
> type void

This is a *declaration*, and as such defines a new abstract type that is
uninhabited, as desired.

- Andreas