[Haskell-cafe] Getting my mind around UArray -> STUArray conversion

Dan Doel dan.doel at gmail.com
Fri Jun 19 21:51:08 EDT 2009

On Friday 19 June 2009 9:43:29 pm Scott Michel wrote:
> wombat :: (IArray UArray e, Ix ix, MArray (STUArray s) e (ST s)) => e
> -> ix -> UArray ix e -> UArray ix e
> wombat val idx mem = (unsafeThaw mem :: ST s (STUArray s ix e)) >>=
> (\mmem -> unsafeFreeze mmem)

Based on the error message and dealing with this sort of thing before, your 
problem is that when you say:

  ":: ST s (STUArray s ix e)"

the s, ix and e there aren't the same as they are in the signature of wombat. 
To make them the same, you need the ScopedTypeVariables extension, and to make 
wombat's signature:

  wombat :: forall e ix s. ...

where the dots are your current signature.

It's possible you'll still have errors, but that will solve the one in your 

-- Dan

More information about the Haskell-Cafe mailing list