Typesafe MRef's

Keith Wansbrough Keith.Wansbrough@cl.cam.ac.uk
Fri, 13 Jun 2003 16:22:11 +0100


> Keith wrote (snipped)
>  > But George Russell's implementation relied on looking up something in
>  > one map with a key obtained from another map.  I thought type-safe
>  > MRefs should disallow this.
> 
> However if you disallow lookup up in one map with a key from another,
> then Ralf Hinze's solution of putting the value inside the key
> uses no type extentions and works perfectly well (though is probably
> not quite what was intended).

No, because update should not return a new key, it should update the 
value of the same key.  In other words,

let (m1,k) = insert empty "A"
    m2 = update m1 k "B"
in
lookup m2 k

should give "B", not "A", just like with MRefs.

--KW 8-)