hsc2hs

hsc2hs: Mutate a C struct with Haskell

荒凉一梦 提交于 2020-01-01 05:34:33
问题 I am trying to write a Haskell program that communicates with C (ultimately for iOS via GHC-iOS). I want it to pass a string from C to Haskell, have Haskell process it and then return some Data types from Haskell to C Structs via hsc2s. I have been unsuccessful at finding a clear, simple tutorial. The only thing Haskell needs from C is the String, nothing else. I have no trouble with the very first part, passing a string to Haskell. testPrint :: CString -> IO () testPrint c = do s <-

Difference between hsc2hs and c2hs?

假如想象 提交于 2019-12-18 10:52:52
问题 What is the difference between hsc2hs and c2hs? I know what hsc2hs is a preprocessor but what does it exactly do? And c2hs can make Haskell modules from C-code, but do I need hsc2hs for this? 回答1: They both have the same function: make it easier to write FFI bindings. You don't need to know about hsc2hs if you chose to use c2hs; they are independent. C2hs is more powerful, but also more complicated: Edward Z. Yang illustrates this point with a nice diagram in his c2hs tutorial: When should I

Difference between hsc2hs and c2hs?

删除回忆录丶 提交于 2019-11-30 00:07:06
What is the difference between hsc2hs and c2hs? I know what hsc2hs is a preprocessor but what does it exactly do? And c2hs can make Haskell modules from C-code, but do I need hsc2hs for this? They both have the same function: make it easier to write FFI bindings. You don't need to know about hsc2hs if you chose to use c2hs; they are independent. C2hs is more powerful, but also more complicated: Edward Z. Yang illustrates this point with a nice diagram in his c2hs tutorial : When should I use c2hs? There are many Haskell pre-processors; which one should you use? A short (and somewhat inaccurate

How to use hsc2hs to bind to constants, functions and data structures?

空扰寡人 提交于 2019-11-27 15:09:39
问题 i need a example how to use hsc2hs, i thought that when i write a header file like: // foo.h #define PI 3.14159 typedef struct { int i1; int i2; } foo; struct foo2 { int i1; int i2; }; int fooFkt(foo f); and then create a hsc file like: import Foreign import Foreign.C #include "foo.h" use hsc2hs : {-# INCLUDE "foo.h" #-} {-# LINE 1 "test.hsc" #-} import Foreign {-# LINE 2 "test.hsc" #-} import Foreign.C {-# LINE 5 "test.hsc" #-} i dont understand it, i thought hat hsc2hs will import all