Browse thread
Two small observations
- William Chesters
[
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: | 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.