On 26-Apr-2000, Jan Brosius <[EMAIL PROTECTED]> wrote:
> Hi,
>
> First I give the following primitive operations
>
> newVar :: a -> ST s (MutVar s a)
>
> readVar :: MutVar s a -> ST s a
>
> writeVar :: MutVar s a -> a -> ST s ()
>
> Next consider the function
>
> f :: MutVar s a -> Mut Var s a
>
> f v = runST (newVar v `thenST` \w ->
>
> readVar w)
>
> 1. What is the type given to newVar v by the typechecker?
Let's see... `v' has type `MutVar s a', and after renaming apart
`newVar' has type `forall a2,s2 . a2 -> ST s2 (MutVar s2 a2)',
so, substituting `Mutvar s a' for `a2', we see that
`newVar v' has type `forall s2 . ST s2 (MutVar s2 (MutVar s a))'.
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.