[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-12-24 (11:00) |
From: | Tom <tom.primozic@g...> |
Subject: | Re: [Caml-list] map and fold |
> > > 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