Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: rossberg@p...
Subject: Re: [Caml-list] Re: Void type?
Chung-chieh Shan wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> wrote in article
> <jwvvec5dv32.fsf-monnier+gmane.comp.lang.caml.inria@gnu.org> 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