caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] False polymorphic
@ 2001-08-09  7:28 Laurent Chéno
  0 siblings, 0 replies; only message in thread
From: Laurent Chéno @ 2001-08-09  7:28 UTC (permalink / raw)
  To: Caml-list

(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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-08-09  7:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-09  7:28 [Caml-list] False polymorphic Laurent Chéno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).