Date: Sat, 23 Oct 1999 18:32:14 +0100
Message-Id: <199910231732.SAA04758@toy.william.bogus>
From: William Chesters <williamc@dai.ed.ac.uk>
To: caml-list@inria.fr
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.
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:27 MET