
First, hi all. I am an haskeller newbie looking forward to conquer the world with a functional language. Part of this conquer involves IMHO writing a nice desktop, using modern features of opengl, to make it portable. But, a question arises: all opengl true type font renderers are written in C++, no one is written in C. If I want to write haskell bindings for such a thing, what can I do? Vincenzo Ciancia

First, hi all. I am an haskeller newbie looking forward to conquer the world with a functional language.
Excellent!
Part of this conquer involves IMHO writing a nice desktop, using modern features of opengl, to make it portable. But, a question arises: all opengl true type font renderers are written in C++, no one is written in C.
If I want to write haskell bindings for such a thing, what can I do?
Go to www.haskell.org, and look at Libraries and Tools. There you will see HOpenGL, which is just what you seek.
http://haskell.org/HOpenGL/
HTH!
--KW 8-)
--
Keith Wansbrough

Go to www.haskell.org, and look at Libraries and Tools. There you will see HOpenGL, which is just what you seek.
I am sorry, I did not specify that I am already using HOpenGL and I am subscribed to their ML. The matter is that there is no binding to a truetype font library in hopengl and I am willing to make it. The problem, as I said, is that every font renderer already available for opengl is written in C++ and I don't know how to make a binding to a C++ library. This is more general than opengl, this problem might arise in the future for something completely unrelated to opengl. It seems that Haskell's FFI can only bind C. How could I solve this problem? Any idea is well accepted. Maybe I have to write a C++ -> C interface for my libary, but I don't know where to start, and besides, I am learning haskell since I want to avoid C and C++... Vincenzo Ciancia

[...] all opengl true type font renderers are written in C++, no one is written in C.
If I want to write haskell bindings for such a thing, what can I do?
Interfacing to C++ is hard because of the mismatch between the Haskell and C++ typesystems. There are two solutions: 1) Make your C++ interface look like COM and use H/Direct. 2) Make your C++ interface look like C (which is more or less Haskell without the type classes) and use an ffi frontend (or raw ffi). We used to do this at Yale. If doing this with Hugs, you have to be sure to link Hugs with a C++ compiler and may need to use 'export "C" { ... }' in header files and compile generated code with a C++ compiler. (The same may well be required if using H/Direct.) The first is best if you want to preserve some of the type structure present in the original code or if you want to want to/can reuse IDL bindings -- Alastair Reid alastair@reid-consulting-uk.ltd.uk Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/
participants (3)
-
Alastair Reid
-
Keith Wansbrough
-
Nick Name