
scooter.phd:
On Fri, Jun 19, 2009 at 7:08 PM, Dan Doel
wrote: Oops, I replied too hastily.
What I wrote in my first mail is a problem, as witnessed by the "ix" and "ix1" in the error message. However, it isn't the main error. The main error is that you have a monadic expression, with type something like:
ST s (UArray ix e)
but the return type of your function is:
UArray ix e
To make a no-op you need to add a runST, something like:
runST (unsafeThaw mem >>= unsafeFreeze)
Actually, I probably wanted runSTUArray. :-)
But even then, I can't manage to get wombat to compile correctly. I'm starting to think that MArray is itself a WOMBAT (waste of money, brains and time), for three reasons:
a) Overly restrictive Monads in which implementation is supported (i.e., ST and IO) b) The triviality of the examples gives no insight as to how they could be used, other than a create array, do something completely trivial and freeze. c) They are evidently very hard to use in a general sense.
Even google-ing for examples just comes up with trivial examples of MArray usage.
Can you just use STUArrays directly without worrying about MArray overloading? writeArray/readArray on ST is just type safe raw memory access, so should be easy.
wombat :: forall e ix s. (IArray UArray e, Ix ix, MArray (STUArray s) e (ST s)) => e -> ix -> UArray ix e -> UArray ix e wombat val idx mem = runSTUArray (unsafeThaw mem >>= return)
Argh. That type is scary overloaded. -- Don