Friday, November 28, 2014

The New LHC.

What is LHC?

The LLVM Haskell Compiler (LHC) is a newly reborn project to build a working Haskell2010 compiler out of reusable blocks. The umbrella organisation for these blocks is the haskell-suite. The hope is that with enough code reuse, even the daunting task of writing a Haskell compiler becomes manageable.

Has it always been like that?

No, LHC got started as a fork of the JHC compiler. A bit later, LHC was reimagined as a backend to the GHC compiler.

Can LHC compile my code?

LHC can only compile very simple programs for now. Stay tuned, though.

Where's development going next?

  1. Better support for Haskell2010.
  2. Reusable libraries for name resolution and type-checking.
  3. Human-readable compiler output. With LLVM, optimisations are less important. We instead focus on generating pretty code.

Tuesday, November 25, 2014

Very minimal Hello World.

The LLVM Haskell Compiler finally coming together. From Haskell parser to name resolution to type checker to desugarer to LLVM backend to GC. Everything is held together with duct tape but it feels great to finally compile and run Hello World.

# cat Hello.hs
{-# LANGUAGE MagicHash #-}
module Main (main) where

import LHC.Prim

main :: IO Unit
main =
  puts "Hello Haskell!"# `thenIO`
  return Unit

entrypoint :: Unit
entrypoint = unsafePerformIO main

Compiling the above file yields a single LLVM program, containing user code and the RTS.

# lli Hello.ll
Hello Haskell!