On support of C99 complex numbers

Maurí­cio CA mauricio.antunes at gmail.com
Fri Oct 23 13:05:19 EDT 2009


I would like to make a formal request for inclusion of complex
numbers in Foreign.C.Types. Which steps should I follow?

Here is a start on what I would write in such request.



  As complex is available in C, libraries can pass then by value
  in function calls, making it difficult to directly wrap such
  functions in Haskell. GNU GSL, for instance, even if actually
  using C < 99, does that with a struct type that is supposed to be
  binary equivalent to C99 double complex.


  My sugestion is to add these:

  CFComplex    --> for 'float complex'
  CDComplex    --> for 'double complex'
  CLDComplex   --> for 'long double complex'

  I believe this is better than trying to use a kind *->* type, as
  that would bring little help when actually wrapping C functions.
  Also, I think it's not important to have field names for real
  and imaginary, as long as we have an easy convertion for
  Data.Complex. Also, if we want to take imaginary and real parts
  in "pure C" Haskell code, we can use available C functions like
  cimag, creal, cimagf, crealf etc.


Thanks for your attention,

More information about the Haskell-prime mailing list