[Haskell-cafe] Interfacing Java/Haskell
CJ van den Berg
cj at vdbonline.com
Fri May 10 11:48:21 CEST 2013
On 2013-05-09 17:04, Hans Georg Schaathun wrote:
> Does anyone have experience with integrating Haskell and Java?
> I have done some searching, finding a lot of pointers but hardly
> anything in terms of evaluation, successes, or caveats.
>
> From what I see Frege looks promising, arguably not haskell I suppose,
> but does it work? Other projects I have seen appear to have reached
> a stand-still for ages.
>
> The background for the question is that I will contribute some control
> algorithms based on machine learning or AI in a larger project. It
> would save me a lot of time if I could write in Haskell, but only
> assuming that interfacing with Java afterwards is trivial compared
> to writing everything in java in the first place. I am, perhaps,
> particularly worried that a Haskell-lookalike for JVM might be
> unable to optimise properly, like not being lazy. Any advice?
I have successfully written Java/Haskell programs using the Java
Native Interface. You can find my JNI to Haskell binding library at
https://github.com/neurocyte/foreign-jni. I am primarily using it to
write Android Apps with Haskell, but I’ve done a little testing with
the standard JVM and it works fine. There is a bare bones
demonstration of a Java/Haskell application at
https://github.com/neurocyte/android-haskell-activity. That is for
Android, but the basic principals are the same for plain JVM integration.
I am currently working on a tool to generate full (or at least fully
usable) Haskell bindings to Java libraries (using foreign-jni),
including being able to implement Java callback interfaces in
Haskell. That is still a work in progress though and I have not yet
published it to github. The intent is to generate a full set of
bindings to the Android API, but it is pretty generic and should work
for any Java API.
--
CJ van den Berg
mailto:cj at vdbonline.com
xmpp:neurocyte at gmail.com
More information about the Haskell-Cafe
mailing list