How ekmett/thc works
THC runs Haskell programs on Truffle, using GHC as the frontend and Graal to specialize Core. The principal workflow is: a developer invokes the driver, Cabal builds the selected package, GHC Core is exported and acquired, the Core is audited and admitted, and THC executes the accepted entry point. Runtime capabilities include two execution backends, lazy values and typed data layouts, concurrency, native foreign calls, polyglot access, and runtime services. The excerpts show the Java driver and runtime entry points, but not Cabal acquisition internals; those links are documented in the README.
Main entry points: Main.java THC driver · Language.java Truffle language · Program.java AST backend · CoreModules.java Core admission
Components 18
Haskell frontend
- Core plugin
bin/plugin.py
Core acquisition
- THC driver
src/main/java/thc/Main.java - JSON transport
src/main/java/thc/Json.java - Core audit
bin/audit-core.py - Core admission
src/main/java/thc/CoreModules.java
Truffle execution
- Truffle language
src/main/java/thc/Language.java - AST backend
src/main/java/thc/runtime/Program.java - Bytecode backend
src/main/java/thc/runtime/BytecodeProgram.java - Program interface
src/main/java/thc/runtime/ExecutableProgram.java - Core representations
src/main/java/thc/runtime/CoreRepresentation.java - Representation inference
src/main/java/thc/runtime/CoreRepresentations.java - Constructor values
src/main/java/thc/runtime/DataLayout.java
Interop and services
- Polyglot access
src/main/java/thc/runtime/ForeignValue.java - Native interop
src/main/java/thc/ForeignBitcode.java - Runtime services
src/main/java/thc/runtime/CoreRuntimeServices.java
Other components
- Developer
- Cabal build
- GHC compiler
Connections 19
- Developer → THC driver: invokes
README.md - THC driver → Cabal build: builds package
README.md - Cabal build → GHC compiler: compiles Haskell
README.md - GHC compiler → Core plugin: exports Core
README.md - THC driver → JSON transport: parses transport
src/main/java/thc/Main.java - THC driver → Core admission: loads Core
src/main/java/thc/Main.java - Core plugin → Core audit: produces audited input
- Core audit → Core admission: admits Core
- THC driver → Truffle language: launches context
src/main/java/thc/Main.java - Truffle language → AST backend: creates backend
src/main/java/thc/runtime/Program.java - Truffle language → Bytecode backend: creates backend
- AST backend → Program interface: implements
src/main/java/thc/runtime/Program.java - Bytecode backend → Program interface: implements
- AST backend → Core representations: uses proofs
src/main/java/thc/runtime/Program.java - AST backend → Representation inference: infers layouts
src/main/java/thc/runtime/Program.java - Core representations → Constructor values: guides storage
src/main/java/thc/runtime/DataLayout.java - Truffle language → Polyglot access: exposes host access
- Core admission → Native interop: admits imports
src/main/java/thc/CoreModules.java - Truffle language → Runtime services: owns runtime services