Sun, 13 Aug 2000 23:21:10 +0200, Sven Panne wrote on cvs-hslibs:
> * Nuke the need for Green Card. The FFI has matured to such
> a state that the only thing really left is %enum, but this
> is not a real hindrance. And because of binary compatibility
> reasons plus transitivity, the #defines/enums in the OpenGL
> headers have identical values on all major platforms
> (M$/Linux/Solaris/HP-UX), so these could easily be hardwired
> into HOpenGL itself.
I am polishing my higher level foreign library and will soon show
the next version: smaller, simpler to use, and beginning to translate
between C strings and Haskell's Unicode.
Foreign functions are convenient. #defines/enums, struct fields and
finding right types are still not. My current goal is to practically
eliminate the need of writing C wrappers, without casm or litlits that
force compilation via C, and of course without passing the Haskell
source through the C preprocessor.
I have an idea to make a tool similar to c2hs, but much lighter.
It will not need to parse and understand C or Haskell syntax. All is
to take a .chs-like Haskell source template and blindly generate a C
program that will #include the required headers and output the real
Haskell source, filling holes with hardcoded computed values. Avoid
the overhead of calling wrappers but keep being portable.
For example
(#const sizeof (glob_t))
will expand to the integer literal,
(#get glob_t gl_pathc)
to an overloaded function whose one of instances has the type
Ptr Glob -> IO CInt
and
(#type attr_t)
to Word32 or whatever is the right type.
The only significant remaining thing is non-constant macros. They
will either have to be put in manually written C function wrappers
or eventually the tool will generate some C wrappers automatically.
Sorry to reinvent the c2hs. I think it should be simple (probably just
one small Main.hs), and it does not work to infer types of functions
from their C types (because of typed pointers, ForeignObj, newtypes)
so foreign import declarations are supposed to be written manually.
The library will help with memory allocation, translating arguments
and results; the tool will fill bits that require access to C headers.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK