
On Sat, 08 Jan 2005 00:59:10 +0100, Bjorn Bringert
You could probably use the "foreign export" feature of the Haskell Foreign Function Interface [1] to make your Haskell function(s) callable from C, and then write a Java Native Interface [2] wrapper in C.
I have found it impossible to call Haskell functions from Java using
this approach, because Java needs foreign code to be compiled as a
shared library, and GHC, on Linux at least, can't do that as far as I
know.
On the other hand a similar approach works well if you want to call
Java methods from a Haskell program. I haven't tried it with Swing,
but I made it work with JDBC a while ago. Here's an example, calling
toString() on a Java Object:
In Haskell:
import Foreign
type JObject = StablePtr ()
foreign import ccall toString :: JObject -> IO JObject
and in C:
#include