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=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B9C90BC69 for ; Sun, 23 Dec 2007 18:21:01 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAFInbkdC+VLrnmdsb2JhbACQCgEBAQEHBAYpk0SEVw X-IronPort-AV: E=Sophos;i="4.24,201,1196636400"; d="scan'208";a="20651049" Received: from wx-out-0506.google.com ([66.249.82.235]) by mail4-smtp-sop.national.inria.fr with ESMTP; 23 Dec 2007 18:21:01 +0100 Received: by wx-out-0506.google.com with SMTP id h27so388655wxd.15 for ; Sun, 23 Dec 2007 09:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; bh=dfHmABmwbnKNQGUr2xgZRxj3qcQD2rWxm32yv7Koxws=; b=VRM7mKzCtPuId9APBgUKwnKzcnUg/qfQVXahvVZB4MWqkgJNpBKMW4cXJQZwR1Y0ThkaheizoaCm6xjKxUl5BLVeR+aVEPZIWS+jOr3RmepzxRXLDgOumUqk9Wa1tLXCVhLLTvkDDyIfgpZfwsPDJ9uw+EwynN5wyt9CYQ8/eYk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; b=GXwITG/z4T1SEjHdzH8JtipndNFqUbOxPinyYM0xBZIdNY8aDgXGC0ruJDvGueZ+NrdwlZ9Kvx604hh48WJ1TsFPIbvKUnh/SKWXqwinT08a8CadWT7AZEyaJxMj3mCscqGb36LighNZf0AFO4IYtLBjHn1vgd1RLcoBK5AAwsI= Received: by 10.70.21.10 with SMTP id 10mr2469000wxu.2.1198430459838; Sun, 23 Dec 2007 09:20:59 -0800 (PST) Received: from ?192.168.0.102? ( [71.68.41.132]) by mx.google.com with ESMTPS id i35sm13517082wxd.34.2007.12.23.09.20.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 23 Dec 2007 09:20:58 -0800 (PST) From: Peng Zang Reply-To: peng.zang@gmail.com To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Type visibility limitation in recursive modules Date: Sun, 23 Dec 2007 12:20:54 -0500 User-Agent: KMail/1.9.7 Cc: "=?iso-8859-1?q?M=E1rk_S=2E?= =?iso-8859-1?q?_Zolt=E1n?=" References: <476E6FB7.6040100@dravanet.hu> In-Reply-To: <476E6FB7.6040100@dravanet.hu> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712231220.56613.peng.zang@gmail.com> X-Spam: no; 0.00; recursive:01 hash:01 abstracting:01 sig:01 struct:01 sig:01 val:01 struct:01 val:01 bool:01 compiler:01 compiler:01 beginner's:01 ocaml:01 bug:01 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I do not know if this is the intended behavior. It may very well be. However, it appears we can easily work around this by simply abstracting the type later. Eg. module rec Aleph : sig type t = Tag of Beth.t end = struct type t = Tag of Beth.t end and Beth : sig type t = Aleph.t list val scandalous : Aleph.t end = struct type t = Aleph.t list let scandalous = Aleph.Tag((* HERE BE DRAGONS *) []) end module Beth = (Beth:sig type t val scandalous : Aleph.t end) # Beth.scandalous;; - - : Aleph.t = Aleph.Tag [] # Aleph.Tag [];; - - : Aleph.t = Aleph.Tag [] # (Aleph.Tag []) = Beth.scandalous;; - - : bool = true Happy Holidays, Peng On Sunday 23 December 2007 09:24:55 am Márk S. Zoltán wrote: > Behold the following code snippet: > > module rec Aleph : > sig > type t = Tag of Beth.t > end = > struct > type t = Tag of Beth.t > end > and Beth : > sig > type t > val scandalous : Aleph.t > end = > struct > type t = Aleph.t list > let scandalous = Aleph.Tag((* HERE BE DRAGONS *) []) > end > > The compiler complains that the empty list after HERE BE DRAGONS has > type 'a list but it is used with type Beth.t. I'd expect the compiler to > discover that those types can be unified via 'a == Aleph.t, since as far > as I can tell, all necessary facts are visible at that point. Replacing > "Beth : sig type t ..." with "Beth : sig type t = Aleph.t list ..." does > away with the error, but I would very much like to keep Beth.t an opaque > type. Is this an intended behavior? And if it is intended, is there a > way to tell the compiler what I really want it to do? > > Thanks in advance for any help. > > Z- > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFHbpj4fIRcEFL/JewRAiRrAJ9lkWenFBHkG2IwRTuRDVN92JCRPQCgjjZV INwvriBZ/NF25J3ApX8lKn8= =UpHJ -----END PGP SIGNATURE-----