Page Status: work in progress

GRIN is a compiler backend and an intermediate language. The goal is to bring the benefits of whole program analysis and optimization for functional languages especially Haskell.
The main benefits are:

The project aim is to provide easy to use compiler backend with convenient intermediate language and framework.

HIGHLIGHT: whole program analysis and optimization



Urban Boquist’s PhD thesis on Code Optimisation Techniques for Lazy Functional Languages .

Paper: A modern look at GRIN, an optimizing functional language back end

Language Frontends

Haskell: GHC/GRIN

It is crutial to use GHC as a Haskel frontend to support the widest range of libraries. GHC/GRIN is GHC is patched to emit STG representation. The STG modules are linked together and processed by the GRIN compiler.

GHC does incremental (per module) compilation. That was the best design decision back then.

The goal of the GRIN project is to explore the design space of whole program optimization an unleash the performance and tooling benefits of it.

GHC/GRIN is a Haskel frontend with the standard tooling support: Cabal and Stack.

Compiling from STG linking the whole program into a single STG file.

Whole program optimization and interprocedural dead code elimination.

Generates small binaries.

No RTS yet. We need to build a new RTS from scratch supporting every GHC primop. TODO: why we need a new RTS.



Working backend, with multiple sample programs.



Initial stub exists.

Reserach papers

Tooling research

Research directions

Related project