From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 17DB3BC57 for ; Thu, 16 Dec 2010 14:31:08 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At4AACajCU3ZRrfCkWdsb2JhbACWCI4uFQEBAQEJCwoHEQQgwVmFSgSOFBo X-IronPort-AV: E=Sophos;i="4.59,355,1288566000"; d="scan'208";a="92512230" Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by mail1-smtp-roc.national.inria.fr with ESMTP; 16 Dec 2010 14:31:08 +0100 X-Originating-IP: 217.70.178.38 Received: from mfilter7-d.gandi.net (mfilter7-d.gandi.net [217.70.178.38]) by relay2-d.mail.gandi.net (Postfix) with ESMTP id 8E2BA2251A8 for ; Thu, 16 Dec 2010 14:31:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at debian.mgt.gandi.net Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by mfilter7-d.gandi.net (mfilter7-d.gandi.net [217.70.178.38]) (amavisd-new, port 10024) with ESMTP id 5utzFSy-FSH4 for ; Thu, 16 Dec 2010 14:31:07 +0100 (CET) X-Originating-IP: 213.144.210.93 Received: from [192.168.1.138] (unknown [213.144.210.93]) (Authenticated sender: louis.gesbert@mlstate.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 4908B225149 for ; Thu, 16 Dec 2010 14:31:07 +0100 (CET) Message-ID: <4D0A14BE.9080305@mlstate.com> Date: Thu, 16 Dec 2010 14:31:42 +0100 From: Louis Gesbert Organization: MLstate User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Implicitely abstracted type Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; abstracted:01 ocaml:01 bug:01 sig:01 struct:01 struct:01 sig:01 ocaml:01 arises:01 75013:01 abstract:01 abstract:01 assert:01 constructor:01 inferred:02 Yesterday I encountered an ocaml error that, if I can now make some sense out of it -- it's not properly speaking a bug -- was quite confusing at first and took me some time to figure out. What happens is that a sum-type defined in a module can implicitely be turned into abstract because of its inner contents. Here is a small example: ------ module F (A : sig type a end) = struct type a = A.a type t = X of A.a end (* if A.a is abstract, the type F.t is made abstract *) module A = F (struct type a end) (* The inferred interface is: module A : sig type a type t end I figure ocaml can't guess what to put in the interface for the definition of t, but maybe an error would be better than silently turning it into abstract ? *) (* it gets confusing in the following use case (and of course if type t has many cases and you just added an abstract type somewhere deep) *) let _ = A.X (assert false) (* the constructor A.X is not found *) (* if t is defined as "X of a" instead of "X of A.a", no problem arises *) ------ I don't know exactly what to do with it, but maybe it should be made an error ? (types escaping their scope usually are) Louis -- Louis Gesbert R & D @ MLstate 15, rue Berlier 75013 Paris