JVM 上的 Haskell?

我想知道是否有办法让 Haskell 在 JVM 上运行(编译或解释) ?

源锻炉上有 JHaskell 但这个看起来空空如也。

GHC 使用 LLVM 作为编译器后端。把 LLVM 编译成 Java 字节码是个好主意还是可能的?或者使用不同的编译器后端?

20161 次浏览

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.

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.

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?)

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.