Passing a matrix from C to Haskell
Simon Marlow
simonmarhaskell at gmail.com
Wed Feb 8 06:20:21 EST 2006
Bulat Ziganshin wrote:
> Hello Chris,
>
> Wednesday, February 08, 2006, 2:35:39 AM, you wrote:
>
> CK> You probably want Foreign.Marshal.Array
>
> CK> http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Foreign-Marshal-Array.html
>
> CK> peekArray :: Storable a => Int -> Ptr a -> IO [a]
>
> i think we should define "secret door" to construct StorableArray from
> a pointer to allow to use full power of MArray interface on foreign
> arrays
You mean this?
-- |Construct a 'StorableArray' from an arbitrary 'ForeignPtr'. It is
-- the caller's responsibility to ensure that the 'ForeignPtr' points to
-- an area of memory sufficient for the specified bounds.
unsafeForeignPtrToStorableArray
:: ForeignPtr e -> (i,i) -> IO (StorableArray i e)
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list