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] Comments on type variables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-06-09 (17:30)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] Comments on type variables
Hello Alain,

There already had been a long thread on the subject in this list.

You are right and I guess all the implemnetors aggree with you :
therés a problem with type constraints.


> A paragraph in the FAQ is somewhat misleading:
> << Polymorphism appears when we introduce type schemes, that is types
>    with universally quantified type variables.
> ...
>    The polymorphism is only introduced by the definition of names during
>    a let construct (either local, or global).
> >>
> The last sentence seems to contradict the first; the programmer doesn't
> introduce type schemes.

The first occurrence of ``we'' means we, type theorists, not we,
actual programmers; in effect, as you said, there is no means for the
Caml programmer to introduce type scheme parameters (or polymorphic
variables as you said). (Except recently for method definitions, and
the notation used could probably be extended to the rest of type

You may also have a look at the french version: I may have made a
mistake or oversimplification when translating into english.

> Also, why are class parameters enclosed in brackets ?
> type 'a t = ...
> but:
> class ['a] t = ...
> and not:
> class 'a t = ...

Ask Yacc! As far as I remember, we needed those explicit brackets to
delimit type parameters of a class from type parameters of types, when
mixing types and classes...

> '_a variables
> -------------
> It is not possible to specify "impure" type variables:

You are right, and it is probably desirable to clarify a lot of examples.

> Variable name in error message
> ------------------------------
> Error messages would be more readable if they retained (when possible)
> variable names:
> # let f (a : 'a) (b : 'b list) = b + 1;;
> This expression has type 'a list but is here used with type int

This is a long standing misfeature of Caml, that is unfortunately not
at all easy to fix.

Best regards,

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