Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] simple typing question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] simple typing question
> 
> I imagine this has been asked and answered before, so I apologize in
> advance.
> 
> Compare these two functions:
> 
> # let f x = List.map (fun y -> y) x ;;
> val f : 'a list -> 'a list = <fun>
> 
> and
> 
> # let f = List.map (fun y -> y) ;;
> val f : '_a list -> '_a list = <fun>
> 
> Why does the second use the '_a type variable instead of 'a?  I thought
> that special type variables only had to do with polymorphic references.
> The FAQ states that the latter expression can't be generalized, but I don't
> really understand why.
> 
> Mike

This is explained in the FAQ of the language either in english

http://pauillac.inria.fr/caml/FAQ/FAQ_EXPERT-eng.html#polymorphisme

ou en français:

http://pauillac.inria.fr/caml/FAQ/FAQ_EXPERT-fra.html#polymorphisme

If you don't understand the explanations, please let me know.

Cordialement,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
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