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.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 203B2BB83 for ; Fri, 1 Sep 2006 22:49:45 +0200 (CEST) Received: from lepore.amnh.org (lepore.amnh.org [216.73.241.12]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k81Kni2J012642 for ; Fri, 1 Sep 2006 22:49:44 +0200 Received: from localhost (localhost [127.0.0.1]) by lepore.amnh.org (Postfix) with ESMTP id 9A4695B773; Fri, 1 Sep 2006 16:49:41 -0400 (EDT) X-Virus-Scanned: amavisd-new at amnh.org Received: from lepore.amnh.org ([127.0.0.1]) by localhost (lepore.amnh.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j0nQAEI5WPEN; Fri, 1 Sep 2006 16:49:40 -0400 (EDT) Received: from [172.16.63.146] (unknown [216.73.248.36]) by lepore.amnh.org (Postfix) with ESMTP id 5E0CA5B765; Fri, 1 Sep 2006 16:49:40 -0400 (EDT) In-Reply-To: <1157138993.22787.34.camel@rosella.wigram> References: <012901c6cdec$64edf490$6a7ba8c0@treble> <1157138993.22787.34.camel@rosella.wigram> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: multipart/alternative; boundary=Apple-Mail-1-595437002 Message-Id: <7E1CAC5D-67CC-4A5C-8DE6-BB2A60A6615B@gmail.com> Cc: OCaml List From: Andres Varon Subject: Re: [Caml-list] Polymorphic variants question Date: Fri, 1 Sep 2006 16:49:39 -0400 To: skaller X-Mailer: Apple Mail (2.752.2) X-j-chkmail-Score: MSGID : 44F89CE8.001 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44F89CE8.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; variants:01 dfns:01 sig:01 val:01 struct:01 constructors:01 dfns:01 sig:01 val:01 struct:01 constructors:01 2006,:98 2006,:98 wrote:01 wrote:01 --Apple-Mail-1-595437002 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Sep 1, 2006, at 3:29 PM, skaller wrote: > > let string_of_term dfns term = match term with > | #qualified_name_t as x -> string_of_qualified_name x This is, indeed, a practical reason why PM are so nice. In the same line of ideas, I wish I could do something like the following : module type S = sig type t val f : t -> int end module A (B : S with type t = [> ]) (C : S with type t = [> ]) : S with type t = [B.t | C.t] = struct type t = [ B.t | C.t ] let f x = match x with | #A.t as x -> A.f x | #B.t as x -> B.f x end Of course the example won't even compile, but I think it reflects the spirit of what I would like to do. I know this is just not possible due to a practical reason (#A.t is expanded to the constructors that it includes, and therefore, A.t has to be fully known at compile time, correct?). Is there a theoretical reason to have this constraint though? Andres --Apple-Mail-1-595437002 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1
On Sep 1, 2006, at = 3:29 PM, skaller wrote:


let string_of_term dfns term =3D match term with

=

=A0 | #qualified_name_t as x = -> string_of_qualified_name x

=

This is, indeed, a practical reason why PM = are so nice. In the same line of ideas, I wish I could do something like = the following :

module type S =3D = sig
= type t
val f : t -> = int
end

module A (B : S with type t = =3D [> ]) (C : S with type t =3D [> ]) : S with type t =3D [B.t | = C.t] =3D struct
type t =3D [ B.t | C.t ] =

let f x = =3D=A0
= match x with
| = #A.t=A0 as x -> A.f x
| = #B.t as x -> B.f x
end

Of course the example won't = even compile, but I think it reflects the spirit of what I would like to = do. I know this is just not possible due to a practical reason (#A.t is = expanded to the constructors that it includes, and therefore, A.t has to = be fully known at compile time, correct?). Is there a theoretical reason = to have this constraint though?

Andres

= --Apple-Mail-1-595437002--