[Arrays] Random Access Times ?

Ron de Bruijn rondebruijn@yahoo.com
Tue, 6 May 2003 12:46:56 -0700 (PDT)


Quoted:
However, if you want to use unboxed arrays, you need
to do something 
like:

instance MArray IOUArray Foo IO where
    unsafeRead (arr :: IOUArray i Foo) i = do
					      (arr2 :: IOUArray i Int) <- castIOUArray
arr
					      v1 <- unsafeRead arr2 (i*2)
					      v2 <- unsafeRead arr2 (i*2+1)
					      return (Foo v1 v2)
End quoting

I understand you just create one large array with the
elements v1 and v2 next to eachother (I 'd never
thought it would be that easy :) ).
There is only a small problem: there is no such
function as unsafeRead or unsaferead, at at least not
in GHC (I saw unsafeThaw, but that also didn't work). 


P.S. I just turned on the fglasgow-exts, but I would
preferabily do it without any extensions, how can I
rewrite the same code, without the extensions?

Greets Ron 




__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com