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=0.0 required=5.0 tests=AWL 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 18811BBAF for ; Wed, 8 Apr 2009 07:16:43 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtsEAGbQ20nZSMDdZGdsb2JhbACBUpQ/GgsDBwcPBbYog3sGhz8 X-IronPort-AV: E=Sophos;i="4.38,431,1233529200"; d="scan'208";a="27257774" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail1-smtp-roc.national.inria.fr with ESMTP; 08 Apr 2009 07:16:42 +0200 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id 49A07FF90D14; Wed, 8 Apr 2009 07:16:42 +0200 (CEST) Received: from [78.43.226.218] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1LrQ9R-0004SY-00; Wed, 08 Apr 2009 07:16:41 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1LrQ9R-0002IR-4S; Wed, 08 Apr 2009 07:16:41 +0200 From: Goswin von Brederlow To: Jacques Garrigue Cc: goswin-v-b@web.de, caml-list@inria.fr Subject: Re: [Caml-list] Subtyping References: <873aclf1z8.fsf@frosties.localdomain> <87bpr86kti.fsf@frosties.localdomain> <20090408.103501.38023937.garrigue@math.nagoya-u.ac.jp> Date: Wed, 08 Apr 2009 07:16:41 +0200 In-Reply-To: <20090408.103501.38023937.garrigue@math.nagoya-u.ac.jp> (Jacques Garrigue's message of "Wed, 08 Apr 2009 10:35:01 +0900 (JST)") Message-ID: <87ocv7ybba.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.21 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX19LRZlgGXkclDzqRa/TQhvsYqxl4Q5rti+1sDJv 627kbO/lPog5aPTmc4Vuz1BoN1VHfJ0wSggPFlUIvC2jKRrR81 sVOxKzG1M= X-Spam: no; 0.00; subtyping:01 iter:01 verbose:01 1.2:98 mfg:98 closures:01 closures:01 caml-list:01 int:01 writes:01 closure:01 encoding:02 objects:02 garrigue:03 garrigue:03 Jacques Garrigue writes: > type 'a base = {x : 'a; fn : 'a -> unit} > type 'b base_op = {bop: 'a. 'a base -> 'b} > type base_wrapper = {base: 'b. 'b base_op -> 'b} > > let l = > let a = {x = 1; fn = print_int} > and b = {x = 1.2; fn = print_float} in > [{base = fun x -> x.bop a}; {base = fun x -> x.bop b}] > > List.iter (fun w -> w.base {bop = fun r -> r.fn r.x}) l > > As you can see, the result is rather verbose, but this works. > Fortunately, closure and objects are usually enough... > > Jacques Garrigue That is exactly what I ment. I knew closures could have "'a. ..." types but I didn't think of encoding the record and the method to call both as closures. MfG Goswin