Browse thread
[Caml-list] False polymorphic
- Laurent_Chéno
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Laurent_Chéno <laurent.cheno@n...> |
| Subject: | [Caml-list] False polymorphic |
(please excuse my poor english) David said well : > # let id x = x;; > val id : 'a -> 'a = <fun> > > This expression is fully polymorphic. > > # let id2 = id id;; > val id2 : '_a -> '_a = <fun> > > This one is not (notice the underscore (_) before the type variable > a). It is a monomorphic type that is right know unknown but will be > determined at first instantiation. and you should read indeed > For further information on this subject, have a look at the FAQ: > http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html#variables_de_types_faibles > I just add this point : > #let id x = x ;; > id : 'a -> 'a = <fun> > #let id3 x = (id id) x ;; > id3 : 'a -> 'a = <fun> > #id3 ;; > - : 'a -> 'a = <fun> > #id3 3 ;; > - : int = 3 > #id3 "abc" ;; > - : string = "abc" > # > You can retain that this '_a problem can be avoided if you explicitly give all expected args. Best regards, Laurent (who never learned english) -- Laurent Chéno Prof. de mathématiques en PSI* et de l'option informatique en MP/MP* Lycée Louis-le-Grand, Paris http://pauillac.inria.fr/~cheno/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr