MArray and runST

Simon Peyton-Jones simonpj@microsoft.com
Fri, 14 Feb 2003 16:04:53 -0000


| > Now, the error message you get is deeply obscure, I grant you.
Trouble
| > is, this variant IS ok:
| >
| >         foo =3D id wibble
| >
| >         wibble :: ((forall s. ST s b) -> b) -> b
| >
| > Why?  For the same reason that this is OK
| >
| >         foo =3D id reverse
| >
| > That, is we can instantiate the type of the argument to a monotype
(a
| > type without for-alls).
|=20
| Sorry, I don't understand yet.  Why isn't the "forall s" in wibble's
type a
| problem?

I'll explain by showing the translation. Here it is for the reverse
example. Notice that we instantiate reverse before passing it to 'id'.
I'm using curly braces for type application.

	foo =3D /\a. id {a} (reverse {a})

Now here's the more complicated version for 'wibble'

	foo =3D  /\s b. id  {(ST s b -> Int) -> Int}=20
		         (\x::(ST s b - >Int). =20
			     wibble {b} (/\f::(forall s1. ST s1 b).  (x
(f {s}))))

Simon