Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] First order compile time functorial polymorphism in Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jun.Furuse@i...
Subject: Re: [Caml-list] First order compile time functorial polymorphism in Ocaml

At Mon, 23 Jun 2003 04:25:18 +1000,
John Skaller wrote:
> In ML style functional programming languages like Ocaml,
> we have what is termed data polymorphism. This provides
> a kind of code reuse we're all familiar with.
> However, there is another kind of polymophism
> which Ocaml does not provide. Two things to consider here:
> 1. Every data structure has a map function.
> 2. User defined algebraic type require a hand written map function

Yes, I agree that writing map or fold function over again and again is 
trivial and boring.

Your approach reminds me polytypic programming or so-called 
"generic programming"[1] in Haskell. I have also considered a bit about 
the possibility of this "generic programming" in O'Caml. Actually, 
I think our "generics" (= G'Caml) has already had allmost of all 
the internal functionalities for so-called "generics" in Haskell
community. Only one possible problem of "generics" on Caml is that
type constructors of Caml is not so "mathematically pure" as Haskell.
I still do not have clear idea how to declare generic case for n-ary
tuples, objects and labeled function types of Caml...

Anyway, "generics" are too general solution for your purpose.
This is not something I can prepare for you in this week. :-)

[1]: Generic Haskell project


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: