Typesafe MRef with a regular monad

Simon Peyton-Jones simonpj@microsoft.com
Fri, 6 Jun 2003 14:47:13 +0100


Yes, one *could* use dynamic types.  But the check would always succeed!
That suggests a lack in the static type system.  It's not surprising:
the soundness depends on the un-forgeability of keys.  So it's
reasonable that there should be some language extension.  I'm just
looking for the minimal such extension.  Finite maps see a bit of a big
hammer.

Simon

| -----Original Message-----
| From: Ralf Hinze [mailto:ralf@informatik.uni-bonn.de]
| Sent: 06 June 2003 14:29
| To: Simon Peyton-Jones; Tim Sweeney; haskell@haskell.org; Ashley
Yakeley
| Subject: Re: Typesafe MRef with a regular monad
|=20
| Am Freitag, 6. Juni 2003 15:23 schrieb Simon Peyton-Jones:
| > Oh bother, I forgot to add that you can of course insert a new value
| > with an old key (suitably typed) and have it overwrite.  Else, as
you
| > say, there would not be much point.
| >
| > Maybe it'd be better to have a separate key-construction function
| >         newKey :: k -> Key k a
| > instead of having insert return a key.
| >
| > S
|=20
| Seriously, isn't this just an application of dynamics? The key
| type allows us to insert a cast when looking up a data structure
| of dynamic values?
|=20
| Cheers, Ralf
|=20