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
Two small observations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-10-25 (18:53)
From: William Chesters <williamc@d...>
Subject: Two small observations
`with' is not fully polymorphic.  For instance, in

	type 'a t = { length: int; elt: int -> 'a }

	let map: ('a -> 'b) -> 'a t -> 'b t =
          fun f t -> { t with elt = f ° t.elt }

the inferred type for map is given by

	val map : ('a -> 'a) -> 'a t -> 'a t

I can see that this is a simple way out of the problem of what to say
if a `with' changes fields in a way inconsistent with the others'
types, but it is a little confusing.

   The other thing is that the compiler doesn't tell you if your type
annotations turn out to be over-optimistic, like that on `map' above.
It would be nice to have the option of having it generate a warning in
these cases.