Haskell on the JVM with Eta • Brian McKenna • YOW! 2017

Learn how Eta compiles Haskell to JVM bytecode, enabling cross-language interop and deployment to JVM platforms while maintaining key Haskell features like laziness and type classes.

Key takeaways
  • Eta is a fork of GHC that compiles Haskell to JVM bytecode instead of native code
  • Performance is currently 4-10x slower than GHC, with significant room for optimization
  • Uses the STG (Spineless Tagless Graph) intermediate representation before generating JVM bytecode
  • Provides Java FFI capabilities to interact with Java code and libraries
  • Successfully tested with 221 Haskell packages that don’t depend on C code
  • Useful for running Haskell on platforms where JVM is required (e.g., Android, enterprise environments)
  • Can expose Haskell functions to be called from Java/Scala code
  • Supports key Haskell features like laziness and type classes
  • Requires patching some GHC libraries to remove C dependencies and replace with Java code
  • Enables integration with Java ecosystem tools like Spark, Kafka, and JavaFX
  • Project originated from GHCVM during Haskell Summer of Code, now maintained by TypeLead company
  • Supports inheritance and subtyping when interfacing with Java code
  • Uses explicit memory allocation and evaluation model similar to GHC’s compilation pipeline