On Mon, Jun 23, 2008 at 1:15 PM, Galchin, Vasili <[EMAIL PROTECTED]> wrote:
>      I tried to write a test value of Word8 without success. Can you give an 
> example?

I'm not quite sure what you would want in such an example. See [1] for
the malloc function. Then you take the result and wrap it with [2]:
 fp <- mallocBytes nbytes >>= newForeignPtr finalizerFree

When you want to use it, use [3] to unwrap fp and get a raw Ptr Word8.
You can pass these to foreign functions any place they expect a
uint8_t *, char * etc.


[1] 
http://www.haskell.org/hoogle/hoodoc.cgi?module=Foreign.Marshal.Alloc&name=mallocBytes&mode=func
[2] 
http://www.haskell.org/hoogle/hoodoc.cgi?module=Foreign.ForeignPtr&name=newForeignPtr&mode=func
[3] 
http://www.haskell.org/hoogle/hoodoc.cgi?module=Foreign.ForeignPtr&name=withForeignPtr&mode=func

-- 
Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to