MArrayt and runST

Thu, 13 Feb 2003 09:56:27 -0000

I appreciate this may have been covered before, but i'm struggling to get
the types
right for the following functions:

firstly I have a function I want to be passed an MArray (so the function
itself is polymorphic and independant of the type of array used). This has a
type similar to:

fn1 :: MArray a Int m => a (Int,Int) Int -> m ()

now I want to produce a wrapper function to provide an MArray of a given
type, and
freeze the result into a non-mutable array, so I have a function like:

wrapper :: MArray (STUArray s) Int (ST s) => ST s (Array (Int,Int) Int)
wrapper = do
	d <- newArray ((0,0),(10,10)) 0
	fn1 d
	unsafeFreeze d

However the problem comes when I try and use runST to run it...

runMatrix :: Array (Int,Int) Int
runMatrix = runST $ wrapper

This is becase 's' escapes
Expected: ST s a -> b
Inferred: (forall s1. ST s1 a) -> a

where am I going wrong?

	Keean Schupke.