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: Hezekiah M. Carty <hcarty@a...>
Subject: Re: [Caml-list] Attach an invariant to a type
On Jan 31, 2008 1:13 PM, Romain Bardou <Romain.Bardou@lri.fr> wrote:
> Wow, how could I forget about private types.
>
> However, you still need the of_int function.
>
> module Subindex: sig
>    type t = private int
>    val make: int -> t
> end = struct
>    type t = int
>    let make n =
>      assert (n >= 10 && x <= 100);
>      n
> end
>

This code does not work for me.  I get a "This fixed type is not an
object or variant" error on the "type t = private int" line.  From the
manual it looks like you would have to use something like this:

type t = private Index of int

to take advantage of private types.  Am I missing something?

Hez