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 in 3.11, again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-01-20 (17:30)
From: Jacques Carette <carette@m...>
Subject: Re: [Caml-list] Private types in 3.11, again
Hmmm, a variant of your code may be exhibiting a bug in ocaml 3.11.0.

In your signature, change the +'a t signature to
    type +'a t = private [< elem_t ]
and remove all annotations from the definition of sprint2.  Then, as 
defined, one gets the error message

File "", line 26, characters 0-223:
Error: Signature mismatch:
       Modules do not match:
           val sprint2 :
             ([< `Bold of 'a list | `Text of string ] as 'a) -> string
       is not included in
         sig val sprint2 : 'a Node.t -> string end
       Values do not match:
         val sprint2 :
           ([< `Bold of 'a list | `Text of string ] as 'a) -> string
       is not included in
         val sprint2 : 'a Node.t -> string

which is not very informative, especially since expanding 'a Node.t 
gives exactly what the compiler reports as the first argument of sprint2.

To coax the compiler to be more helpful, on places the definition of 
sprint2 outside a module (but still in the same file as Node), and 
instead the result is:

File "", line 30, characters 26-29:
Error: This expression has type Node.elem_t list but is here used with type
         'a Node.t list
       Type Node.elem_t = [ `Bold of Node.elem_t list | `Text of string ]
       is not compatible with type
         'a Node.t = [< `Bold of Node.elem_t list | `Text of string ]
       Types for tag `Text are incompatible

[That point to the seq in sprintf2 seq].  Here is where the 
potential bug is: how is string incompatible with string?
[If this is a bug, I'll add it to the database]