>>>>> Simon Marlow <[EMAIL PROTECTED]> writes:

    >> Another issue that I've encountered on the same BLAS project:
    >> is there an officially sanctioned way to get at the ByteArray#
    >> or MutableByteArray# underlying the UArray and STUArray types? 
    >> When I import ArrayBase, getting at the ByteArray# of a UArray
    >> is no problem. However, things are not as simple for an
    >> STUArray. I have resorted to using my own slightly hacked
    >> version of MArray in order to get at the MutableByteArray#. Is
    >> there some better method to do all this?

    Simon> I'm not sure why you say things aren't as simple for
    Simon> STUArray - the definition of this datatype is exported from
    Simon> ArrayBase the same as UArray.

My mistake. I threw in the whole `kitchen sink' in trying to solve my
problems , and I neglected to narrow down my imports to determine what
would be really necessary.

In tracking this down, I did notice that the IOUArray data constructor
is not exported by MArray (and that is why I produced my own version
that does export the data constructor). What would be the recommended
method to convert an STUArray into a IOUArray (without copying)? 
Essentially, I have a function that returns ST s (STUArray s _ _), and
I want to take the returned value into the IO monad as an IOUArray.

    Simon> Anyway, you're right that there's no easy way to pass these
    Simon> arrays to foreign functions, like you can with the old
    Simon> MutableArray and ByteArray types (at least for "unsafe" FFI
    Simon> calls, 'cause the array lives in the Haskell heap).  Now
    Simon> that MArray/IArray have settled down, it's probably worth
    Simon> adding this support to the compiler.

For my concerns, that would be great.

Cheers,

  Martin

Reply via email to