[Haskell] ANN: llvm-

Marnix Klooster Marnix.Klooster at infor.com
Tue Dec 23 05:51:09 EST 2008

Hi all,

For completeness: I'm assuming http://darcs.serpentine.com/llvm is the
site for the LLVM Haskell bindings, according to the earlier


-----Original Message-----
From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org]
On Behalf Of Lennart Augustsson
Sent: Monday, December 22, 2008 8:40
To: Haskell; Haskell Cafe
Subject: [Haskell] ANN: llvm-

We have now released version of the Haskell LLVM bindings.
(This release that is quite incompatible with the old 0.0.2 release.)

LLVM is a virtual machine and the bindings allow you to generate code
for this virtual machine.  This code can then be executed by a JIT or
written to a file for further processing by the LLVM tools.

The LLVM bindings has two layers.  You can either use the low level
bindings that is just the same as the C bindings for the LLVM.  This
level is quite unsafe as there is very little type checking.
The recommended way is a high level binding (somewhat less complete)
which eliminates many errors by leveraging the Haskell type system.

A simple example, generating code for a function that adds two numbers
and then calling it from Haskell:

import Data.Int
import LLVM.Core
import LLVM.ExecutionEngine

cgplus :: CodeGenModule (Function (Int32 -> Int32 -> IO Int32)) cgplus =
    createFunction InternalLinkage $ \ x y -> do
        r <- add x y
        ret r

main = do
    ioplus <- simpleFunction cgplus
    let plus = unsafePurify ioplus

    print $ plus 20 22

    Bryan O'Sullivan
    Lennart Augustsson
Haskell mailing list
Haskell at haskell.org

More information about the Haskell mailing list