From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 079FBBCA2 for ; Wed, 17 Aug 2005 08:55:09 +0200 (CEST) Received: from ash25e.internode.on.net (ash25e.internode.on.net [203.16.214.182]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j7H6t7pF010574 for ; Wed, 17 Aug 2005 08:55:08 +0200 Received: from rosella (ppp32-205.lns1.syd6.internode.on.net [59.167.32.205]) by ash25e.internode.on.net (8.12.9/8.12.6) with ESMTP id j7H6t2Jj006028; Wed, 17 Aug 2005 16:25:02 +0930 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] Snd question From: skaller To: Jon Harrop Cc: caml-list@yquem.inria.fr In-Reply-To: <200508162242.50803.jon@ffconsultancy.com> References: <161F0D30A699A84A8B7435B62BCE33B30360E19F@APS-MSG-01.southpacific.corp.microsoft.com> <200508161734.38909.jon@ffconsultancy.com> <20050816181604.GA21719@furbychan.cocan.org> <200508162242.50803.jon@ffconsultancy.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-Y6kjCsH/VGlYS7a6rEo2" Date: Wed, 17 Aug 2005 16:55:02 +1000 Message-Id: <1124261702.6858.21.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 X-Miltered: at concorde with ID 4302DF4B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ad-hoc:01 polymorphism:01 sml:01 'list':01 functors:01 functor:01 functor:01 wrote:01 sourceforge:01 sourceforge:01 polymorphic:01 structures:01 int:01 argument:01 X-Attachments: type="application/pgp-signature" name="signature.asc" X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 --=-Y6kjCsH/VGlYS7a6rEo2 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2005-08-16 at 22:42 +0100, Jon Harrop wrote: > Has anyone done any ad-hoc polymorphism (if that's the right jargon, I me= an=20 > the equivalent of "+" for both int and float in SML) for containers? I=20 > haven't finished it yet but I've recently been playing with a term-level=20 > mini-Caml interpreter that I was going to add this functionality to. So=20 > "fold", "map" and so on are built into the language and can be applied to= the=20 > built-in data structures set, list and array.=20 Jay's Functorial ML describes how to do this properly:=20 map, fold, etc, can be applied to any polynomial type (a type built out of sums, products, and induction). This is polyadic =3D functorially polymorphic, not ad hoc. The rules are things like:=20 map (a,b) =3D (map f a, map g b) (where is the parallel composition of f and g). Basically, things like 'list', 'tree', etc, are functors, and map is just a function which takes a functor argument and returns a map for that functor. That is, this 'map', 'fold' etc are polyadic: they accept a functor and return another functor. --=20 John Skaller --=-Y6kjCsH/VGlYS7a6rEo2 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBDAt9EsRp8/9aGVGsRAgRcAJ9qBNzIaUsU4daHTM7x+1EzAfVVFgCeOJYJ 7H6b/qh0QjVqNYttcsP+xD8= =ud96 -----END PGP SIGNATURE----- --=-Y6kjCsH/VGlYS7a6rEo2--