Question

I'm wondering if there is some way to make Haskell run on the JVM (compiled or interpreted)?

There exists JHaskell on Sourceforge but this one seems to be empty and dead.

GHC uses LLVM as compiler backend. Would it be a good idea or possible to compile LLVM to Java bytecode? Or maybe use a different compiler backend?

Was it helpful?

Solution

You may want to investigate Frege. Quoting from that page:

"Frege is a non-strict, pure functional programming language in the spirit of Haskell."

"Frege programs are compiled to Java and run in a JVM."

Based on a brief perusal of the language specification, Frege looks to be nearly a Haskell clone. Perhaps the phrase "in the spirit of Haskell" is simpy intended to set the proper expectation.

OTHER TIPS

Haskell works beautifully on the JVM. See Eta, a project that brings full GHC 7.10.3 Haskell onto the JVM with type-safe Java interop.

The only language I know that is close to haskell in the JVM is CAL. CAL is heavily based on haskell but it doesn't have all haskell's features. The type system is similar to Haskell 98, and syntactic sugar like do notation is missing.

Here's a comparison of Haskell and CAL: CAL for Haskell Programmers

The eclipse plugin is very polished and useful.

Note that CAL is part of the Open Quark framework.

There are big but surmountable impediments to GHC building to the JVM:

http://www.haskell.org/haskellwiki/GHC:FAQ#Why_isn.27t_GHC_available_for_.NET_or_on_the_JVM.3F

(Got a spare year or two to make it happen?)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top