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
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: 2008-02-01 (10:00)
From: Keiko Nakata <keiko@k...>
Subject: Re: [Caml-list] Attach an invariant to a type

> 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.

With best regards,