[Haskell-cafe] [ANN] Haskell FFI Tutorial

Donn Cave donn at avvanta.com
Thu Nov 13 06:23:40 UTC 2014


quoth Evan Laforge <qdunkan at gmail.com>
 
> Doesn't hsc2hs give you the size with #size?  I feel like I'm not
> understanding your approach.

Maybe it does, and I only need a clue to the syntax.  I have seen
it used only for the size of the struct;  I'm looking for the size
of a field - and devoid of parentheses or other adornments, so I
can tack it onto something like Word or Int.  You could define
type aliases for other variable-size foreign types, like Float8
etc. and use #fieldsize to select them.

One of your objections was that you're obliged to code field
types in the .hsc file, and if you make an error or the types
are changed later in the C code, hsc2hs doesn't notice.
This approach gives you a way to partially derive a foreign
type from the size of the field.

I don't know language-c.  Lots of interesting potential there
if it works well.

	Donn


More information about the Haskell-Cafe mailing list