Version française
Home     About     Download     Resources     Contact us    
Browse thread
map and fold
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
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