问题
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?
回答1:
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.
回答2:
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.
回答3:
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.
- main site: http://openquark.org/Welcome.html
- download page: http://openquark.org/Download.html
- Source on Github: https://github.com/levans/Open-Quark
回答4:
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?)
来源:https://stackoverflow.com/questions/7261039/haskell-on-jvm