From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p1LFwrO5016363 for ; Mon, 21 Feb 2011 16:58:53 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkYSAFgaYk1ii1tVWmdsb2JhbACEH5NPMY4WARYKCwYPBiGqEDyCHIQ/iQkBBAQBgSKDQXYEhQ2KQQ X-IronPort-AV: E=Sophos;i="4.62,200,1297033200"; d="scan'208";a="88409218" Received: from nm15.bullet.mail.sp2.yahoo.com ([98.139.91.85]) by mail4-smtp-sop.national.inria.fr with SMTP; 21 Feb 2011 16:58:47 +0100 Received: from [98.139.91.66] by nm15.bullet.mail.sp2.yahoo.com with NNFMP; 21 Feb 2011 15:56:44 -0000 Received: from [98.139.91.23] by tm6.bullet.mail.sp2.yahoo.com with NNFMP; 21 Feb 2011 15:56:44 -0000 Received: from [127.0.0.1] by omp1023.mail.sp2.yahoo.com with NNFMP; 21 Feb 2011 15:56:44 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 589446.88927.bm@omp1023.mail.sp2.yahoo.com Received: (qmail 49872 invoked by uid 60001); 21 Feb 2011 15:56:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1298303804; bh=NMHw9/HO9AFWpfskjqr17STP9k6jTzI/V8XWkyPr0aA=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=csOsWKI94MbuJEqiVcc+bK8irlKRAVT3UBWezVaB8bGTQYRbxmcnFvgcck1F/VDrnbDWnY/cDyFd2sC9m8mu8tCh5S4AcNBtaW8xq2bn6hbgLRQKvWKfbCcZjSVzUDU7iYGvY/OzcVAm0mmwLjmjhinFxX40BIwLYRnqNLqsnvY= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=bKvfxulCynOY4HybJh4HrSueR/FScxdvHo8q90V8vllbTbzWGLHzAG7ugQ1BFtUfYkj55PQnM/zvvWihEqxqzf9qjY2Ocsj4XPCOEw6OQqiyAHCyBTYz7uu8MICoeMs5aLZLmu93boxlVOMR6vH7kFsKb9pVV0waR/sR9asr7I0=; Message-ID: <241708.48122.qm@web111501.mail.gq1.yahoo.com> X-YMail-OSG: ZG9UE7EVM1l0pNJoKer54sIlGVIGwpDxJTh.1Crj3WN9c82 hFMeOkosCsRO6wX__cBtg7TyBkAUwSPuCYJpIvFVbwfd0kWogN98YH2Fcp09 RG4qrUi.zgnECn2aaWMuYnIZh3xZmRWB.BppeFBhwSMULqSjZiAcO6FNw207 w1LRMYOaxfbsb3wkvHCr6FQ4961YfUYBryqJoHXqO2rilaPWP9S4wNRIe7vC mONwWzPKm2jKfHBJ.DmBS1dNBri4whftiaSnJlRDnl1_DXM3_IhveORMXNf2 LWkbit2u2WlrIjtWtQkGHQ5CgA6vGxuzQULvfWksM2z.o0.dxXTui0y7pjRm .y4ps_2Y7eDE98asjUbq4mssD3H4ufSE4Boo_7skPRbiTcQHc0Nyf4U1Hv73 uZRBDSn0_TLni Received: from [213.205.70.206] by web111501.mail.gq1.yahoo.com via HTTP; Mon, 21 Feb 2011 07:56:43 PST X-Mailer: YahooMailClassic/11.4.20 YahooMailWebService/0.8.109.292656 Date: Mon, 21 Feb 2011 07:56:43 -0800 (PST) From: Dario Teixeira To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p1LFwrO5016363 Subject: [Caml-list] Constraining abstract type to be of a given subtype Hi, In a signature FOO, I'm trying to constrain an abstract type kind_t to be a subtype of Kind.t (please see code below). However, I get a compiler error when I declare an actual struct Foo1 which supposedly obeys signature FOO: Type declarations do not match: type 'a kind_t = [ `A ] is not included in type 'a kind_t = 'a constraint 'a = [< Kind.t ] Any hints as to what is wrong here? Thanks in advance for your help! Best regards, Dario Teixeira module Kind: sig type t = [ `A | `B | `C ] val to_string: t -> string end = struct type t = [ `A | `B | `C ] let to_string = function | `A -> "A" | `B -> "B" | `C -> "C" end module type FOO = sig type custom_t type 'a kind_t = 'a constraint 'a = [< Kind.t ] type 'a t = int * custom_t * 'a kind_t val make: int -> custom_t -> 'a kind_t -> 'a t val string_of_custom: custom_t -> string val string_of_kind: 'a kind_t -> string end module Foo1: FOO = struct type custom_t = float type 'a kind_t = [ `A ] type 'a t = int * custom_t * 'a kind_t let make id custom kind = (id, custom, kind) let string_of_custom = string_of_float let string_of_kind k = Kind.to_string (k :> Kind.t) end