Wednesday, April 8, 2009

Hello world!

After weeks of development, lhc is finally able to interpret Hello World!

david@desktop:lhc$ cat HelloWorld.hs
module Main where
main = putStr "Hello world\n"
david@desktop:lhc$ ghc -O2 -fext-core HelloWorld.hs -c
david@desktop:lhc$ lhc build HelloWorld.hcr > HelloWorld.grin
Parsing core files...
Tracking core dependencies...
Translating to grin...
Removing dead code...
Printing grin...
david@desktop:lhc$ wc -l HelloWorld.grin
8054 HelloWorld.grin
david@desktop:lhc$ lhc eval HelloWorld.hcr
Parsing core files...
Tracking core dependencies...
Translating to grin...
Removing dead code...
Hello world
Node (Aliased 251 "ghc-prim:GHC.Prim.(#,#)") (ConstructorNode 0) [Empty,HeapPointer 263]


Supported primitives include: indexCharOffAddr#, newPinnedByteArray#, *MutVar, *MVar.

Exceptions are currently ignored and the heap is never garbage collected. However, since I'm evaluating the GRIN (as opposed to translating it to LLVM or C), adding these features should be easy as cake.

2 comments:

  1. This is very cool, Lemmih, to see the proposed toolchain:

    david@desktop:lhc$ ghc -O2 -fext-core HelloWorld.hs -c
    david@desktop:lhc$ lhc build HelloWorld.hcr > HelloWorld.grin

    You should write more about this design decision -- since it is very cool.

    ReplyDelete