ANN: bindings-SDL 1.0.2, the domain specific language for FFI description

Hi,
This package is to be used with hsc2hs. (hsc2hs is called
automatically if you use Cabal.) It's a self-contained set of
macros used to create a Haskell wrap for a C interface. They
follow the idea that it's better to have a C-like wrap code
first and then write Haskell-like code on top of that than going
directly from C to Haskell style.
Hackage link: http://hackage.haskell.org/package/bindings-DSL
Wiki documentation: http://bitbucket.org/mauricio/bindings-dsl
The fancy 'domain specific language' comes from 'binding-SDL'
macros hability to describe a C interface. Instead of writing
Haskell or preprocessor code, you can use 'bindings-DSL' macros
to describe the interface you want to wrap without knowledge of
how that description translates to preprocessor or Haskell code.
Suppose, for instance, you have the following C struct:
struct example_struct{
int n;
struct example_struct *p;
}
It will be described like this:
#starttype struct example_struct
#field n , CInt
#field p , Ptr

I did not notice when this was released, but I saw it on Hackage yesterday and, with it, wrote some of the easiest bindings to a fairly complex C API I've written in a while. This package is excellent! Thank you for sharing it. My only complaint is that the macros get confused if you use a Haskell type that has a single quote in it. - Jake

I did not notice when this was released, but I saw it on Hackage yesterday and, with it, wrote some of the easiest bindings to a fairly complex C API I've written in a while. This package is excellent! Thank you for sharing it.
Thanks. My hope is that it saves as much time from users as the support from this community saved for me.
My only complaint is that the macros get confused if you use a Haskell type that has a single quote in it.
Can you give me an example? Best, Maurício

Maurício CA wrote:
My only complaint is that the macros get confused if you use a Haskell type that has a single quote in it.
Can you give me an example?
It turns out that I read the documentation incorrectly, but here is what
I was trying to do.
I had two structs, one of which used the other as a field type. I was
using the generated identifier of the first as the type for the second,
so it had the form c'STRUCT_NAME. So the field macro looked like this:
#field foo , c'STRUCT_NAME
It did not like this, complaining about the single quote.
I have since noticed the

I had two structs, one of which used the other as a field type. I was using the generated identifier of the first as the type for the second, so it had the form c'STRUCT_NAME. So the field macro looked like this:
#field foo , c'STRUCT_NAME
It did not like this, complaining about the single quote.
I have since noticed the
notation in the documentation. Perhaps the actual bug is that this notation was not pointed out in prose?
I believe I forgot to write a section with that information, as well as others one would like to know from start. I wrote a new section trying to fix that in 'how to use it' topic. http://bitbucket.org/mauricio/bindings-dsl/wiki/HowToUseIt I'm not sure I have already got to a point where documentation is clear and complete enough but not too long and boring. If you also thing some parts of documentation were not helpful, or if more is missing, please let me know. Thanks for your feedback. Maurício

Maurício CA wrote:
I believe I forgot to write a section with that information, as well as others one would like to know from start. I wrote a new section trying to fix that in 'how to use it' topic.
Very nice. I think that is clear enough.
I'm not sure I have already got to a point where documentation is clear and complete enough but not too long and boring. If you also thing some parts of documentation were not helpful, or if more is missing, please let me know.
Quite the contrary, with that one exception, I found the documentation to be among some of the best I have used. I especially like the numerous examples you included. - Jake
participants (2)
-
Jake McArthur
-
Maurício CA