[Haskell-cafe] Regarding Haskell FFI for C/C++ (Passing of String)

rajendra prasad rajendradprasad at gmail.com
Thu Mar 22 15:10:31 CET 2012


Hi,

I have just started learning Haskell FFI. I am trying to send a string from
hastell to a C function. For this, I am required to convert the haskell
string to byte string. I have two methods to achieve this task. Both are
listed below:

1) import Foreign.C.String
    let arg1 = map castCharToCChar "Hello" :: [CChar]

2) import qualified Data.ByteString.Char8 as B
    f = B.pack "Hello"

I just wanted to know the optimal way to achieve this task. Please suggest
the optimal way of doing this. If there is any other way, please share it.

Also, please suggest me any good tutorial to start with Haskell FFI for
C/C++.

Thank you very much.


Regards,
Rajendra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120322/e3fffdb7/attachment.htm>


More information about the Haskell-Cafe mailing list