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 11A1A7F1C9 for ; Fri, 9 Nov 2012 15:25:10 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of didier.cassirame@gmail.com) identity=pra; client-ip=209.85.214.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="didier.cassirame@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of didier.cassirame@gmail.com designates 209.85.214.182 as permitted sender) identity=mailfrom; client-ip=209.85.214.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="didier.cassirame@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ob0-f182.google.com) identity=helo; client-ip=209.85.214.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="postmaster@mail-ob0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvIDAJ4RnVDRVda2k2dsb2JhbABEhhm9KQgjAQEBAQkJCwkUBBwHgkgEGQEbHgMSEA8CJgIkAREBBQEiG4dvAQMPnAGCb4thT4J4hHoKGScNWYh1AQUMgRSQJ4ETA5V7jmIWKYQS X-IronPort-AV: E=Sophos;i="4.80,745,1344204000"; d="scan'208";a="180846276" Received: from mail-ob0-f182.google.com ([209.85.214.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 Nov 2012 15:25:09 +0100 Received: by mail-ob0-f182.google.com with SMTP id wc20so6842462obb.27 for ; Fri, 09 Nov 2012 06:25:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=yx+t3Q9JMCQVp2yk6h2Ru1KfQxSKh6GyXiP1WQOLbnU=; b=kyxSUXqhGvI/5TDZcl9OJZip0SRH1jaiBiHPyVWkXFKiYrPf8xXFsQZjqYW3kKwTGB 0OYe4GJ22eliTRJxLT/1ZPAOjMNL3UDzyORFZ+R2/SCl9wCJCiR8VuQbyfW0iKPUgsIc gW6Og1k0qibN4MQtopw/jGTCGIdqtri2kfWkGs0puLED043A3kC6h+jPpYg8PxrJv+5D BBKHEDnG3Hg09y3WNMOllxlVXE6J+tPLWPv7IjJIsyjzG9OWGuA3pOh8ivi0MBjAvUqn GFvvxsgsStqK4hJqyAeUWOt8hjUAIFDx0S/mrfFSDZvxAZJHEC3Ded9bjl5YJ/zfcFjZ Yj2g== MIME-Version: 1.0 Received: by 10.60.172.138 with SMTP id bc10mr8097413oec.33.1352471109322; Fri, 09 Nov 2012 06:25:09 -0800 (PST) Received: by 10.60.137.198 with HTTP; Fri, 9 Nov 2012 06:25:09 -0800 (PST) Date: Fri, 9 Nov 2012 15:25:09 +0100 Message-ID: From: Didier Cassirame To: "caml-list@inria.fr" Content-Type: text/plain; charset=UTF-8 Subject: [Caml-list] parameterized classes, modules & polymorphic variants Dear caml-list, I have been trying recently to combine classes, modules and variants in the following fashion: module A1 = struct class ['a] t = object constraint 'a = [>`a] method m : 'a -> string = function `a -> "a" | `a1 -> "a1" | _ -> "_" end end;; module A2 = struct class ['a] t = object constraint 'a = [>`a] method m : 'a -> string = function `a -> "a" | `a2 -> "a2" | _ -> "_" end end;; module A3 = struct class ['a] t = object constraint 'a = [>`a] method m : 'a -> string = function `a -> "a" | `a3 -> "a3" | _ -> "_" end end;; module type A = sig class ['a] t : object constraint 'a = [>`a] method m : 'a -> string end end;; type m = (module A);; let l: m list = [ (module A1); (module A2); (module A3)];; -------------------------------- Unfortunately the list typecheck fails. However, making a list of class instances from A1.t, A2.t, A3.t succeed, with the type: [> `a | `a1 | `a2 | `a3 ] ct list ct being defined as equal to A.t. I thought that perhaps I should parameterize the type m from the type parameter 'a of A.t to solve my problem, but I am not sure of the syntax, or if it's the problem. Does anyone have an idea? didier