Inside 206-105

Existential Pontification and Generalized Abstract Digressions

c2hs

Call and fun: marshalling redux

This part six of a six part introduction to c2hs. We finally talk about what ostensibly is the point of c2hs: calling C functions from Haskell. c2hs, due to its knowledge of the C headers, can already do the work for generating FFI imports. The call hook simply tells c2hs to generate the FFI import, […]

  • June 30, 2010

Marshalling with get and set

This part five of a six part introduction to c2hs. Today, we explain how to marshal data to and from C structures. An important note. There is a difference between struct foo and foo; c2hs only considers the latter a type, so you may need to add some typedefs of the form typedef struct foo […]

  • June 25, 2010

First steps in c2hs

This is part four of a six part tutorial series on c2hs. Today we discuss the simple things in c2hs, namely the type, enum, pointer, import and context directives. Prior art. All of the directives c2hs supports are tersely described in the “tutorial” page (which would perhaps be more accurately described as a “reference manual”, […]

  • June 23, 2010

Principles of FFI API design

This is part three of a six part tutorial series on c2hs. Today, we take a step back from the nitty gritty details of FFI bindings and talk about more general design principles for your library. On the one hand, writing an FFI binding can little more than churning out the glue code to let […]

  • June 18, 2010

Setting up Cabal, the FFI and c2hs

This part two of a six part introduction to c2hs. Today, we discuss getting the damn thing to compile in the first place. Reader prerequisites. You should know how to write, configure and build a vanilla Cabal file for pure Haskell. Fortunately, with cabal init, this is easier than ever. I'll talk about how to […]

  • June 14, 2010

The Haskell Preprocessor Hierarchy

This post is part of what I hope will be a multi-part tutorial/cookbook series on using c2hs (Hackage). The Haskell Preprocessor Hierarchy (this post) Setting up Cabal, the FFI and c2hs Principles of FFI API design First steps in c2hs Marshalling with get an set Call and fun: marshalling redux What's c2hs? c2hs is a […]

  • June 11, 2010