Questions tagged [hsc2hs]

hsc2hs is used to write Haskell interfaces to C code. The hsc2hs command can be used to automate some parts of the process of writing Haskell bindings to C code.

The hsc2hs command can be used to automate some parts of the process of writing Haskell bindings to C code. It reads an almost-Haskell source with embedded special constructs, and outputs a real Haskell file with these constructs processed, based on information taken from some C headers. The extra constructs deal with accessing C data from Haskell...

Read more here: Writing Haskell interfaces to C code: hsc2hs

The source code can be looked at here : http://git.haskell.org/packages/hsc2hs.git

(It is mirrored on github here)

19 questions
2
votes
0 answers

sizeof, offsetof, and alignment via TemplateHaskell

I wonder if someone has implemented analogues of hsc2hs pragmas via TemplateHaskell? It feels like it should be doable, since TH runs on target platform at compile time, and GHC always has a C compiler lying around. This could be useful as another…
artem
  • 363
  • 1
  • 9
2
votes
2 answers

Haskell: How do I get the values of #define-d constants?

In a Haskell program, what's the best way to use constants defined in C headers?
Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
1
vote
1 answer

When using hsc2hs, introduction of #include directive in haskell source results in numerous errors

I'm writing a Haskell program that is supposed to know some details about X11 state, so I try to define an FFI that would call relevant X11 shared libraries' symbols. I generally follow the instructions from the wikibook. When I add an include…
Ignat Insarov
  • 4,660
  • 18
  • 37
0
votes
1 answer

What is the purpose of a repeated parameter in this #let construct of hsc2hs?

In the following code, it looks like numarray only takes one parameter, so I'm not sure what the repeated #t is used for, but it causes an abnormal exit of hsc2hs when not all are present: #let numarray t = "\ foreign import ccall unsafe mxIs%s ::…
bbarker
  • 11,636
  • 9
  • 38
  • 62
1
2