Food for thought: Numeric.Special
Keith Wansbrough
Keith.Wansbrough@cl.cam.ac.uk
Fri, 06 Jun 2003 11:06:56 +0100
> I think the only sane way to do this is with FFI, and I think the GNU
> Scientific Library (GSL) is the best target for this. Some people may
> have access to the IMSL or NAG libraries, but I doubt that most do. I
> also believe that GSL is available for all of the targets currently
> served by the various Haskell compilers, including Windows
[..]
> Most (all?) of the functions are pure, and basically accept doubles or
> ints as parameters and return a double. So, it's not a hard job, but
> there are a zillion functions. I am willing to (slowly) tackle the job
> since I already have it started.
>
> Thoughts? Comments?
Automate!
You must avoid actually writing the import declarations for each
function by hand. With any luck, you can write a script to
automatically turn the .h file into a .hs file, and save yourself all
the work. I believe there are tools to assist in this; see a recent
posting on the Haskell FFI list by Simon Marlow:
>>>
You want to use a tool to make all this easier. There are various
tools available: green-card, c2hs, and hsc2hs are the most
commonly-used ones these days. Alastair Reid wrote a good comparison
of the various tools (can't remember the link off hand though).
There are examples of hsc2hs code in the libraries - particularly
fptools/libraries/unix has examples of doing defines, enums and
structs. Examples of green-card stuff can be found in
fptools/libraries/HGL and fptools/libraries/X11. Take a look at
Manuel's GtkHS for c2hs examples.
<<<
--KW 8-)