Version française
Home     About     Download     Resources     Contact us    
Browse thread
Attach an invariant to a type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Keiko Nakata <keiko@k...>
Subject: Re: [Caml-list] Attach an invariant to a type
Hello.

> type t = private int isn't legal.  Most types get completely erased
> during compilation, but records and variants have code generated by the
> compiler based off their type declaration to construct a value of that
> type.  A plain int doesn't have this compiler-generated constructor, so
> it can't be private in this way.
> 
> That said, I'd appreciate a simple system to do the kind of checking you
> want at the site of an explicit typecast.

Maybe a previous discussion on the list is interesting to you.
Among this active discussion, the following post by Pierre Weis
looks good new to you.

http://caml.inria.fr/pub/ml-archives/caml-list/2007/11/76aa857050497ee6cf62db65eadd567a.en.html

With best regards,
Keiko