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.3 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id AE726BC0B for ; Sun, 24 Dec 2006 12:00:07 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBOB07MZ003112 for ; Sun, 24 Dec 2006 12:00:07 +0100 Received: by nf-out-0910.google.com with SMTP id q29so4148650nfc for ; Sun, 24 Dec 2006 03:00:07 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=c3aWMq4sQzlrhelotg5Eb9VZuppSnl7em4B21CTD4B5MKoYErQ6NyEQE3U8RpUHmYAlwQbzbI70Xelj95VGhnbCOi/S4CzXuWlvnrsbmCeoKM3mdzEj9rSJ8uVBLXPMwq2HQwe+WTBATROU4OrwS0wQfdHytvZIIOloAqA270EA= Received: by 10.82.114.3 with SMTP id m3mr340894buc.1166958006994; Sun, 24 Dec 2006 03:00:06 -0800 (PST) Received: by 10.82.100.16 with HTTP; Sun, 24 Dec 2006 03:00:06 -0800 (PST) Message-ID: Date: Sun, 24 Dec 2006 12:00:06 +0100 From: Tom To: skaller Subject: Re: [Caml-list] map and fold Cc: Andrej.Bauer@andrej.com, caml-list@yquem.inria.fr In-Reply-To: <1166931734.25424.41.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_87960_21737802.1166958006965" References: <1166786286.6549.24.camel@rosella.wigram> <458DC1BC.5090802@fmf.uni-lj.si> <1166931734.25424.41.camel@rosella.wigram> X-j-chkmail-Score: MSGID : 458E5DB7.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 458E5DB7.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 datatypes:01 datatypes:01 caml-list:01 unsafe:01 unsafe:01 define:01 define:01 data:02 data:02 poly:02 poly:02 chalmers:02 chalmers:02 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_87960_21737802.1166958006965 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline > > > However in Ocaml at least you cannot actually write a single > definition for map in terms of a single fold -- you have to > write out fold for each data type, and worse, even given that > you still need to write out map for each data type too, > following an idiomatic pattern. > > How could Ocaml be extended to get rid of this unsafe > verbosity? > > Even if the resulting generic operators weren't first class, > it would still be useful to define 'map' once and be done > with it. > Hm... maybe you have in mind something called "polytypic programming" Example: pmap :: Regular d => (a->b) -> d a -> d b A generalisation to all regular datatypes of the normal map on lists . Applies a function to all elements in a structure. Take a look at http://www.cs.chalmers.se/~patrikj/poly/ - Tom ------=_Part_87960_21737802.1166958006965 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline

However in Ocaml at least you cannot actually write a single
definition for map in terms of a single fold -- you have to
write out fold for each data type, and worse, even given that
you still need to write out map for each data type too,
following an idiomatic pattern.

How could Ocaml be extended to get rid of this unsafe
verbosity?

Even if the resulting generic operators weren't first class,
it would still be useful to define 'map' once and be done
with it.

Hm... maybe you have in mind something called "polytypic programming"

Example: pmap :: Regular d => (a->b) -> d a -> d b
   
A generalisation to all regular datatypes of the normal map on lists . Applies a function to all elements in a structure.

Take a look at http://www.cs.chalmers.se/~patrikj/poly/

- Tom
------=_Part_87960_21737802.1166958006965--