Monday, December 29, 2014
Nursery sizes.
Intel i5-3210M cpu, 3072 KB L3 cache. Not sure why the CPU stalls with the tiny nurseries.
Friday, December 12, 2014
Test suite for Haskell2010
To keep track of progress and to ward off regressions, the test suite now have a section for Haskell2010 compatibility checks:
The tests only cover a small part of the Haskell2010 specification and none of them pass yet.
# runhaskell Main.hs -t Haskell2010 --plain | tail -n 4 Test Cases Total Passed 0 0 Failed 6 6 Total 6 6
The tests only cover a small part of the Haskell2010 specification and none of them pass yet.
Thursday, December 4, 2014
Compiling to JavaScript.
Lots of very interesting things are possible when everything (including the runtime system) is translated to LLVM IR. For example, compiling to JavaScript becomes trivial. Consider this ugly version of Hello World:
Notice the 'List' and 'Unit' types, and the 'thenIO' and 'unpackString#' functions. There's no syntactic sugar in LHC yet. You can get everything sugar-free these days, even Haskell compilers.
Running the code through the LLVM dynamic compiler gives us the expected output:
Neato, we have a complete Haskell application as a single LLVM file. Now we can compile it to JavaScript without having to worry about the garbage collector or the RTS; Everything has been packed away in this self-contained file.
{-# LANGUAGE MagicHash #-} module Main (main) where import LHC.Prim putStrLn :: List Char -> IO Unit putStrLn msg = putStr msg `thenIO` putStr (unpackString# "\n"#) main :: IO Unit main = putStrLn (unpackString# "Hello World!"#) entrypoint :: Unit entrypoint = unsafePerformIO main
Notice the 'List' and 'Unit' types, and the 'thenIO' and 'unpackString#' functions. There's no syntactic sugar in LHC yet. You can get everything sugar-free these days, even Haskell compilers.
Running the code through the LLVM dynamic compiler gives us the expected output:
# lli Hello.ll Hello World!
Neato, we have a complete Haskell application as a single LLVM file. Now we can compile it to JavaScript without having to worry about the garbage collector or the RTS; Everything has been packed away in this self-contained file.
$ emcc -O2 Hello.ll -o Hello.js # Compile to JavaScript using # emscripten. $ node Hello.js # Run our code with NodeJS. Hello World! $ ls -lh Hello.js # JavaScript isn't known to be # terse but we're still smaller # than HelloWorld compiled with GHC. -rw-r--r-- 1 lemmih staff 177K Dec 4 23:33 Hello.js
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?
- Better support for Haskell2010.
- Reusable libraries for name resolution and type-checking.
- 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!
Subscribe to:
Posts (Atom)