From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id EF6D8BBAF for ; Wed, 21 Jan 2009 11:48:51 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAKuMdkmCNhAB/2dsb2JhbADMTYVz X-IronPort-AV: E=Sophos;i="4.37,299,1231110000"; d="scan'208";a="19943469" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Jan 2009 11:48:50 +0100 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id n0LAma6H008575; Wed, 21 Jan 2009 19:48:37 +0900 (JST) Date: Wed, 21 Jan 2009 19:48:27 +0900 (JST) Message-Id: <20090121.194827.214243292.garrigue@math.nagoya-u.ac.jp> To: carette@mcmaster.ca Cc: darioteixeira@yahoo.com, caml-list@yquem.inria.fr Subject: Re: [Caml-list] Private types in 3.11, again From: Jacques Garrigue In-Reply-To: <49760A0C.5080204@mcmaster.ca> References: <865755.99476.qm@web111508.mail.gq1.yahoo.com> <49760A0C.5080204@mcmaster.ca> X-Mailer: Mew version 4.2 on Emacs 22.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; hmmm:01 bug:01 ocaml:01 annotations:01 bug:01 mismatch:01 sig:01 val:01 sig:01 val:01 node:01 node:01 compiler:01 recursive:01 recursive:01 Hi Jacques, From: Jacques Carette > 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 "bug2.ml", line 26, characters 0-223: > Error: Signature mismatch: > Modules do not match: > sig > val sprint2 : > ([< `Bold of 'a list | `Text of string ] as 'a) -> string > end > 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. Unfortunately, type errors for private row types can be hard to understand when the types themselves are complex. As I pointed in my answer to Dario, the private row type Node.t has to be recursive for it to be an instance of a recursive type. [< elem_t] does not define a recursive type, but just adds a row variable on its outermost variant. > 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 "bug2.ml", 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 List.map 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] The bug is in only in the error message; which seems another instance of the problem you reported in your previous mail. There is however a real type error, because Node.t, as it has a private row, cannot be an instance of the fixed type elem_t. Cheers, Jacques Garrigue