English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2004-09-30 (10:13)
From: Keith Wansbrough <Keith.Wansbrough@c...>
Subject: Re: [Caml-list] Factoring HOFs [was Re: C++ STL...]
> 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>

You want it to have type

(forall 'a 'b 'f. ('a -> 'b) -> ('a 'f -> 'b 'f))
   -> ('b -> 'c) 
   -> ('a -> 'b) 
   -> 'a 'f 
   -> 'b 'f

but OCaml doesn't allow nested quantifiers (i.e., higher-rank

It actually wouldn't be very hard to support, if you're prepared to
accept the need for the occasional type annotation - see

--KW 8-)

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners