Using LLVM in Haskell

Tweet
Posted on January 27, 2014 by Kwang Yul Seo
Tags: Haskell, LLVM

Stephen Diehl’s Implementing a JIT Compiled Language with Haskell and LLVM is a good introductory material on how to use LLVM in Haskell. It explains how to build a compiler for a toy language, Kaleidoscope in Haskell.

Because LLVM is a compiler infrastructure written in C++, we need a Haskell binding for LLVM. The tutorial uses llvm-general. llvm-general depends on another package named llvm-general-pure which provides a pure Haskell AST (no FFI needed) for LLVM IR. BTW, Bryan O’Sullivan’s LLVM binding is deprecated in favor of llvm-general.