Haskell and C---functions returning more than one value

I’ve finally found some time to play with c2hs again. This time I had a quick look at passing pointers to C functions. Here’s what I found, in a rather short format:

That is, the former is an out argument ((It seems it always receives a pointer to an integer instance containing the value 0.)) while the latter is an inout argument.

A C function like this:

which is defined like this in haskell

will return a tuple of two integers, the first one is the returned value from foo the other is the inout argument to foo.

This means that it’s fairly simple to deal with APIs that follow the convention that functions return an error code and that the last argument is the actual result of the function.

⟸ My first GNOME commits PaiMei on Python 2.5 ⟹
Leave a comment