Version française
Home     About     Download     Resources     Contact us    
Browse thread
cyclic types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: William Lovas <wlovas@s...>
Subject: Re: [Caml-list] cyclic types
On Sun, Jan 30, 2005 at 08:05:23AM +0200, Radu Grigore wrote:
> Only one (small) problem remains. I do not understand this:
> 
> # type t = t StringMap.t option;;
> The type abbreviation t is cyclic
> # type t = Some of t StringMap.t | None;;
> type t = Some of t StringMap.t | None

The first is a type abbreviation, while the second is a datatype
declaration.  They both introduce a new type, in some sense: the first does
so by asserting its equality to some existing type, while the second does
so by defining one or more coercions from existing types to the new type
(i.e. constructors).  Only the second can refer to the type being defined
on the right-hand side, for the reasons mentioned earlier.

cheers,
William