From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id DFD3F7EC41 for ; Wed, 24 Oct 2012 20:10:05 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of madroach@gmerlin.de) identity=pra; client-ip=80.91.229.3; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gclci-caml-list@m.gmane.org"; x-sender="madroach@gmerlin.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of gclci-caml-list@m.gmane.org designates 80.91.229.3 as permitted sender) identity=mailfrom; client-ip=80.91.229.3; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gclci-caml-list@m.gmane.org"; x-sender="gclci-caml-list@m.gmane.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of postmaster@plane.gmane.org designates 80.91.229.3 as permitted sender) identity=helo; client-ip=80.91.229.3; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gclci-caml-list@m.gmane.org"; x-sender="postmaster@plane.gmane.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoEFAPgtiFBQW+UDgWdsb2JhbABEi2ikOAGRWCMBARYmJ4JME4FxiCebHaFFjyqDJAOVcpMr X-IronPort-AV: E=Sophos;i="4.80,640,1344204000"; d="scan'208";a="178784188" Received: from plane.gmane.org ([80.91.229.3]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 24 Oct 2012 20:10:05 +0200 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TR5P2-0002PJ-3h for caml-list@inria.fr; Wed, 24 Oct 2012 20:10:04 +0200 Received: from stgt-d9be5a7a.pool.mediaways.net ([217.190.90.122]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 24 Oct 2012 20:10:04 +0200 Received: from madroach by stgt-d9be5a7a.pool.mediaways.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 24 Oct 2012 20:10:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Christopher Zimmermann Date: Wed, 24 Oct 2012 20:03:10 +0200 Message-ID: <20121024200310.9c639f43a97263423e113500@gmerlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: stgt-d9be5a7a.pool.mediaways.net X-Newsreader: Sylpheed 3.2.0 (GTK+ 2.24.13; x86_64-unknown-openbsd5.2) X-Validation-by: madroach@gmerlin.de Subject: [Caml-list] typing mutually recursive classes Hi, I have a problem with typing a system of mutually recursive classes. This piece of code fails to compile: class a = object end and b = object method foo: a -> int = fun s -> 3 end;; Error: The universal type variable 'a cannot be generalized: it escapes its scope. But this compiles fine: class a = object end class b = object method foo: 'a. (#a as 'a) -> int = fun s -> 3 end;; What I actually want to do is this: class element id (registry :#registry) = object method registry = registry end and registry = object val set = [] method register :'a. (#element as 'a) -> unit = fun s -> set <- s :: set end Any ideas how to do this without parametrizing the classes? Christopher