
Hello! I have a Java application, which has a lot of GUI and one complex algorithm. I spent many months writing and debugging that algorithm, but it still has a lot of bugs. At the moment, I am thinking about implementing that algorithm in Haskell, while leaving the GUI in Java. I would like to know whether it is possible to write algorithmic (let's call them back-end) parts of a system in Haskell and user interface in Java? Can Haskell and Java parts of a system co-operate? Will such a hybrid system run on Windows and Linux? Are there any tutorials about this? Has someone already tried it? Thanks in advance Dmitri Pissarenko ----- Ende der weitergeleiteten Nachricht -----

On Fri, Jan 07, 2005 at 04:56:14PM +0100, Dmitri Pissarenko wrote:
I would like to know whether it is possible to write algorithmic (let's call them back-end) parts of a system in Haskell and user interface in Java?
If all else fails, you can "simply" split the program in two separate, communicating processes. Best regards, Tomasz

Dmitri Pissarenko wrote:
I would like to know whether it is possible to write algorithmic (let's call them back-end) parts of a system in Haskell and user interface in Java?
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. /Bjorn [1] http://www.cse.unsw.edu.au/~chak/haskell/ffi/ [2] http://java.sun.com/docs/books/tutorial/native1.1/

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

In article
<20050107165614.o2eckk08owk048sw@confixx.p15142389.pureserver.info>,
Dmitri Pissarenko
Can Haskell and Java parts of a system co-operate?
See my JVM-Bridge, https://sourceforge.net/projects/jvm-bridge/ -- Ashley Yakeley, Seattle WA
participants (5)
-
Ashley Yakeley
-
Ben Horsfall
-
Bjorn Bringert
-
Dmitri Pissarenko
-
Tomasz Zielonka