[Haskell-cafe] ByteString FFI

2006-11-12 Thread Donn Cave
How do people like to set up their foreign I/O functions to return ByteStrings? I was a little stumped over this yesterday evening, while trying to write ` recv :: Socket - Int - Int - ByteString ' Doc says `Byte vectors are encoded as strict Word8 arrays of bytes, held in a ForeignPtr, and can

Re: [Haskell-cafe] ByteString FFI

2006-11-12 Thread Duncan Coutts
On Sun, 2006-11-12 at 10:49 -0800, Donn Cave wrote: How do people like to set up their foreign I/O functions to return ByteStrings? I was a little stumped over this yesterday evening, while trying to write ` recv :: Socket - Int - Int - ByteString ' Doc says `Byte vectors are encoded as

Re: [Haskell-cafe] ByteString FFI

2006-11-12 Thread Donald Bruce Stewart
donn: How do people like to set up their foreign I/O functions to return ByteStrings? I was a little stumped over this yesterday evening, while trying to write ` recv :: Socket - Int - Int - ByteString ' Doc says `Byte vectors are encoded as strict Word8 arrays of bytes, held in a

Re: [Haskell-cafe] ByteString FFI

2006-11-12 Thread Donn Cave
On Mon, 13 Nov 2006, Donald Bruce Stewart wrote: And for custom data (not just C strings), if the withCString* functions don't quite fit, you can always pack the foreign Ptr into a ByteString by stepping inside the ByteString constructor:

Re: [Haskell-cafe] ByteString FFI

2006-11-12 Thread Donald Bruce Stewart
donn: On Mon, 13 Nov 2006, Donald Bruce Stewart wrote: And for custom data (not just C strings), if the withCString* functions don't quite fit, you can always pack the foreign Ptr into a ByteString by stepping inside the ByteString constructor: