Self-hosting since 2026

A Haskell compiler, written by AI.

AIHC is a modern, self-hosting Haskell compiler. It targets native machine code, LLVM IR and WebAssembly.

Features

Built to run the Haskell people actually write.

Three goals, in priority order: compatible with GHC, faster where GHC is slow by design, and reusable piece by piece.

GHC-compatible

Not Haskell 2010 plus a few extras. AIHC accepts GHC's extensions and ships the GHC.* modules that Hackage packages expect. It builds aeson, text, containers and vector.

Parallel by default

Parsing, name resolution, type checking and code generation are scheduled over every core. The 54 modules of text build in 3.2 seconds, against 28.0 for GHC at -O0.

Whole-program optimization

GHC optimizes one module at a time. AIHC sees the whole program before it generates code, which is how its -Os binaries come out a tenth of the size.

Three backends

Native machine code for AMD64 and ARM64, LLVM IR, and wasm32. One middle end, one runtime and one garbage collector serve all three.

Self-hosting

AIHC compiles AIHC. The compiler it produces compiles itself again, and the two executables are identical, byte for byte.

Owns every stage

Its own preprocessor, parser, type checker, optimizer, object emitter and runtime. No stage shells out to a tool it cannot change, so no bottleneck is out of reach.

A real runtime

A generational, incremental garbage collector with bounded pauses. Green threads that run in parallel. Software transactional memory.

Reusable libraries

The compiler is a set of packages: aihc-cpp, aihc-parser, aihc-resolve, aihc-tc and more. Each is meant to be useful without the rest.

From source to machine code, without leaving the building

  1. Preprocessaihc-cpp
  2. Parseaihc-parser
  3. Resolveaihc-resolve
  4. Type-checkaihc-tc
  5. DesugarSystem FC
  6. OptimizeGRIN
  7. Emitnative · LLVM · wasm

Performance

Measured against GHC, on every commit.

Each number is AIHC divided by GHC 9.14.1 for the same programs. Lower is better, and 1.00× is parity.

Compile time -O0

0.12×

About eight times faster to compile.

Artifact size -Os

0.10×

Executables a tenth of the size.

Runtime -O2

0.94×

Slightly ahead of GHC's optimized code.

Native backend, geometric mean over 13 benchmarks on an Apple M4 Pro, 13 November 2026. GHC has no -Os, so sizes compare against GHC at -O1. The LLVM and Wasm backends, every machine and the full history are on perf.aihc.app.

How it's made

Designed by a human. Typed by robots.

A person holds the architecture and reviews every change. AI agents write the code: ChatGPT, Claude Opus and Qwen-Coder all contribute. They also write the tests, the benchmarks, the design documents and the blog.

The first commit landed in March 2026. Seven months later the compiler built itself.

Try it on your own code.

Clone the repository, build the compiler and run the hello-world example. The user guide has the full instructions.

% git clone https://github.com/ai-haskell-compiler/aihc
% cd aihc
% cabal run exe:aihc -- build examples/hello-world/Main.hs