[Haskell-cafe] How can I pass IOUArrays to FFI functions?

Bulat Ziganshin bulat.ziganshin at gmail.com
Tue Aug 21 03:38:29 EDT 2007


Hello Stefan,

Tuesday, August 21, 2007, 10:08:59 AM, you wrote:

> Your code is broken in a most evil and insidious way.

and this code, too? :)

freezeSTUArray :: Ix i => STUArray s i e -> ST s (UArray i e)
freezeSTUArray (STUArray l u marr#) = ST $ \s1# ->
    case sizeofMutableByteArray# marr#  of { n# ->
    case newByteArray# n# s1#           of { (# s2#, marr'# #) ->
    case unsafeCoerce# memcpy marr'# marr# n# s2# of { (# s3#, () #) ->
    case unsafeFreezeByteArray# marr'# s3# of { (# s4#, arr# #) ->
    (# s4#, UArray l u arr# #) }}}}

> Unreproducable bugs are rarely reported, but they do add to people's
> impression of how unstable a language/library is.




-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list