Typesafe MRef's

Keith Wansbrough Keith.Wansbrough@cl.cam.ac.uk
Mon, 16 Jun 2003 09:58:27 +0100


George Russell writes:

> So what does the function
>     insert2 val1 val2 =
>        let
>           (m1,k1) = insert empty (Just val1)
>           (m2,k2) = insert m1 (Just val2)
>           m3 = update m2 k1 Nothing
>        in
>           isJust (lookup m3 k2)
> return?  It looks to me as if it returns True if val1 and val2 have
> different types, False if they have the same type.  So you have now
> got a way of comparing two types for equality, and so a rather
> roundabout reimplementation of Dynamic.

I think I'm missing something... why is this?  Do you only allow one
value of each type?  It seems to me that updating k1's value should
not affect k2's.

--KW 8-)