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
Private types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Allsopp <dra-news@m...>
Subject: Private types
I'm trying to play with the new private type abbreviations in OCaml

If I write:

module type S =
  type t = private int
  val create : int -> t

module M : S =
  type t = int
  let create x = x

let x = M.create 0;;

Shouldn't I now be able to say:

string_of_int x;;

But I get a type error... I'm struggling to see what difference the private
declaration has made, therefore.

I thought that the point of private types was that you could deconstruct
them... so values of type M.t are valid wherever an int is used but not the

Or have I missed something? <prepares to be embarrassed...>