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

2009-06-23 Thread Ryan Ingram
This is the best I could come up with. We let the compiler prove that s is irrelevant to the MArray instance for a particular instance of STUArray, and package up that knowledge using an existential type. We can then extract the instance for any type; in particular, the instance for the current

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

2009-06-22 Thread Scott Michel
On Fri, Jun 19, 2009 at 7:08 PM, Dan Doeldan.d...@gmail.com 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

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

2009-06-22 Thread Don Stewart
scooter.phd: On Fri, Jun 19, 2009 at 7:08 PM, Dan Doeldan.d...@gmail.com 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

Re[2]: [Haskell-cafe] Getting my mind around UArray - STUArray conversion

2009-06-22 Thread Bulat Ziganshin
Hello Scott, Monday, June 22, 2009, 10:23:42 PM, you wrote: wombat :: forall e ix s. (IArray UArray e, Ix ix, MArray (STUArray s) e (ST s)) = e - ix - UArray ix e - UArray ix e http://haskell.org/haskellwiki/Library/ArrayRef#Reimplemented_Arrays_library Unboxed arrays now can be used in

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

2009-06-19 Thread Scott Michel
I'm trying to get my mind around how to thaw and then freeze a UArray. Theoretically, what I've written below should be a no-op, but I keep getting typing errors that I can't figure out. GHCI 6.10.3 says: Couldn't match expected type `UArray ix a' against inferred type `ST s (STUArray

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

2009-06-19 Thread Dan Doel
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

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

2009-06-19 Thread Daniel Fischer
Am Samstag 20 Juni 2009 03:51:08 schrieb Dan Doel: 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 -

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

2009-06-19 Thread Dan Doel
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