[Arrays] Random Access Times ?

Hal Daume III hdaume@ISI.EDU
Tue, 6 May 2003 15:09:54 -0700 (PDT)


You need -fglasgow-exts to get the type signatures.  you can get around it
with:

instance MArray IOUArray Foo IO where
  unsafeRead arr = do
    arr2 <- myCast
    ...
    where myCast :: IOUArray i Foo -> IO (IOUArray i Int)
          myCast = unsafeCastIOUArray

> 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). 

oh come on, do you really believe that?

Prelude Data.Array.MArray> :info MArray
-- MArray is a class
class (HasBounds a, Monad m) => MArray a :: (* -> * -> *) e m :: (*
                                                                  ->
*) where {
    newArray ::
        forall i. (Ix i) => (i, i) -> e -> m (a i e)
        {- has default method -};
    newArray_ ::
        forall i. (Ix i) => (i, i) -> m (a i e)
        {- has default method -};
    Data.Array.Base.unsafeRead ::
        forall i. (Ix i) => a i e -> Int -> m e;
    Data.Array.Base.unsafeWrite ::
        forall i. (Ix i) => a i e -> Int -> e -> m ();
    }



perhaps importing Data.Arary.Base might help :)

 - hal