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] C++ STL and template features compared with OCaml parametric polymorphism and OO features
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@j...>
Subject: Re: [Caml-list] Factoring HOFs [was Re: C++ STL...]
On Wednesday 29 September 2004 16:32, Florian Hars wrote:
> I made the same error at first, but this is a completely different
> function:

Yipes! Ok, so I'm missing some typing subtlety. Why does this end up with a 
single polymorphic type:

# let map_2 m g f x = m g (m f x);;
val map_2 : ('a -> 'b -> 'b) -> 'a -> 'a -> 'b -> 'b = <fun>
# let mapmap2 g f x = map_2 g f x;;
val mapmap2 : ('a -> 'a) -> ('a -> 'a) -> 'a list -> 'a list = <fun>

Rather than being equivalent to:

# let mapmap g f x = g ( f x);;
val mapmap : ('a -> 'b) -> ('c -> 'a) -> 'c list -> 'b list = <fun>

It looks like the "m" argument to map_2 is assumed to have the same type when 
applied to "f x" as when applied to "g (f x)". Sounds like this might be 
related to polymorphic recursion...


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