[Haskell-cafe] Instead of Haskell running on the JVM is there a way for Haskell to call a JVM language ...
jpmoresmau at gmail.com
Tue Nov 20 08:01:30 CET 2012
You may want to have a look at my little HJVM project on Github (
https://github.com/JPMoresmau/HJVM). Promise, I'll put in on Hackage some
day. Basically it provides FFI wrappers and some c code to be able to start
a JVM and call Java methods, etc from Haskell.
On Tue, Nov 20, 2012 at 7:53 AM, Mathijs Kwik <mathijs at bluescreen303.nl>wrote:
> KC <kc1956 at gmail.com> writes:
> > Instead of Haskell running on the JVM is there a way for Haskell to
> > call a JVM language (or generate bytecode) to access the Java class
> > libraries when needed?
> I once did a small test to get this working.
> It's not that hard, but needs some work. It's fine for exposing a few
> functions though.
> Basically it's a 2-step process, eased by using a makefile or similar
> You have to compile your haskell code into a shared object (.so on
> linux, .dll on windows), which includes the haskell runtime (rts).
> This library can be called from c.
> A small pitfall is that you first need to do a call to initialize the
> haskell runtime, and when you're done using it, close it.
> This is most easily just tied to your c/java program's main
> initialization functions.
> Java is able to load/use these shared libraries through JNI.
> Of course you lose your platform-independance, so if you want your java
> application to work on multiple platforms / OSses, you need to build
> shared objects for all of them.
> Last but not least:
> You have to export the haskell functions you want through FFI.
> Also, make sure they use raw data types such as CString, as that what C
> and java will give you and expect back.
> So basically you go Haskell FFI <-> C <-> Java JNI
> I'm sorry I cannot give you any links or code, because I'm in a bit of a
> hurry. But google and the ghc docs are your friend.
> > Or
> > Is there a way for a JVM language or bytecode to call Haskell when
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe