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.0 required=5.0 tests=AWL,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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 82211BBC1 for ; Thu, 6 Mar 2008 02:52:15 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAANLczkfAXQInh2dsb2JhbACQeQEBAQgKKZNXhws X-IronPort-AV: E=Sophos;i="4.25,454,1199660400"; d="scan'208";a="9012509" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 06 Mar 2008 02:52:15 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m261qEVj020961 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 6 Mar 2008 02:52:15 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAANLczkdA6bjni2dsb2JhbACQeQEBAQgEBAkKEQWTWYcL X-IronPort-AV: E=Sophos;i="4.25,454,1199660400"; d="scan'208";a="8054463" Received: from wr-out-0506.google.com ([64.233.184.231]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Mar 2008 02:52:14 +0100 Received: by wr-out-0506.google.com with SMTP id c57so2816665wra.9 for ; Wed, 05 Mar 2008 17:52:13 -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:content-type:content-transfer-encoding:content-disposition:message-id; bh=mXJcpijRBvbqDy424ktmilqNI+YVWBauB+6g1RZ5HOQ=; b=RcjAZGftJkIFw3+QOtg5pw70omc1NpJGbeqT8d0WmydBkdrWh7JHQsrtSlvfaiM/jOI6AvE6bFZ8dy0IgeT6oU20By5uOivSf/mosN4Zg+1wwSDsjBpCi+2gKMNj7ScpntsZV9CYOdmMgEWUS0D2/h69TTCk/1eZzaqgMktjCow= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:reply-to:to:subject:date:user-agent:content-type:content-transfer-encoding:content-disposition:message-id; b=LebX/id66oTl6PtxIMdeLgJ+BZzw9VsuJRoYLlbUI5XzmuaxP5DtqVyaZ2Eh5vIoIbOg6ABvTaCgThnNEGTpRcEXrbzQIiq01NwtZkfLT51MtbFA8foBcKBSQvbdJSrw68JowWJMJspmIwL9f9nx72pXR2PDp6lpjb534oF7aWE= Received: by 10.100.46.10 with SMTP id t10mr8531434ant.54.1204768333792; Wed, 05 Mar 2008 17:52:13 -0800 (PST) Received: from tama-chan ( [24.99.180.210]) by mx.google.com with ESMTPS id k77sm3151833rnb.13.2008.03.05.17.52.12 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Mar 2008 17:52:13 -0800 (PST) From: Peng Zang Reply-To: peng.zang@gmail.com To: caml-list@inria.fr Subject: specifying the type of an argument with more than one #classpath Date: Wed, 5 Mar 2008 20:52:06 -0500 User-Agent: KMail/1.9.7 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803052052.10651.peng.zang@gmail.com> X-Miltered: at concorde with ID 47CF4E4F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; hash:01 notation:01 subtype:01 foo:01 foo:01 val:01 foobar:01 getx:01 peng:98 peng:98 constructor:01 constraint:01 constraint:01 argument:02 argument:02 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I am aware that when specifying the type of an argument to a function, one can use the "#classpath" notation to specify "any subtype of classpath". Eg: class type foo = object method foo : string end;; # let takesomefoo (x:#foo) = x;; val takesomefoo : (#foo as 'a) -> 'a = However, I cannot figure out how to specify more than one such constraint. Eg. I want to specify an argument that is foo-able and bar-able like this: class type bar = object method bar : string end # let takesomefooable_and_barable (x:#foo #bar) = x;; The type constructor bar expects 0 argument(s), but is here applied to 1 argument(s) Which shows I'm clearly not syntactically expressing this correctly. I checked the manual and it doesn't seem possible... How do I do this or workaround it? I am familiar with class definitions which allow you to do this: class ['a] foobar (x:'a) = object constraint 'a = #foo constraint 'a = #bar method getx = x end;; But I don't see how to specify such constraints in a normal function on the type of an argument. Is there some simple trick people have found for specifying various type constraints on arguments? Thanks in advance, Peng -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFHz05KfIRcEFL/JewRAjD4AJ9hexh+HUP5h2aavCbCXWR8JoVReQCePBBz FIXqFDT3NEhLgtQZwrU7E54= =qonr -----END PGP SIGNATURE-----