[Haskell-cafe] Re: Complex C99 type in Foreign

Maurí­cio briqueabraque at yahoo.com
Sun Feb 1 20:32:19 EST 2009


>>>> Are there plans to include C99 'complex' type
>>>> in Foreign, maybe as CFloatComplex, CDoubleComplex
>>>> and CLongDoubleComplex? (...)

>>> A separate library for new types to add to Foreign would be the easiest
>>> way forward. (...)

>> If it's not true, i.e., I could actually have some
>> arbitrary sized parameter as argument to a function
>> or as a return value (and not its pointer), what
>> did I saw wrong? (...)

> Oh, you mean you need to teach the compiler about
 > unboxed complex types?

I think so. Take this, for instance:


#include <complex.h>
double complex ccos(double complex z);
float complex ccosf(float complex z);
long double complex ccosl(long double complex z);


To bind to ccos* functions I believe I would need
a native CComplex. The GSL numeric library also
makes use of something like that, although it
defines its own 'complex' structure.

I'm writing a binding to the standard C library,
and at the same time collecting a list of standard
types that could be usefull in Foreign. I'm thinking
about writing a ticket to ask for inclusion of a few
of them. 'int32_t' and 'int64_t' as, say, CInt32 and
CInt64 could be nice for portability.

Maurício



More information about the Haskell-Cafe mailing list