Wednesday, September 20, 2006

Yhc.Core API available

Yhc.Core is now a publically available and somewhat supported API! There are no docs on it, but check out the Yhc repo and see src/compiler98/Yhc/Core. Just add "import Yhc.Core" at the top and you can do all cool sorts of things.

Step 1 is to generate Core files, with the .ycr extension. If you are compiling Yhc adding scons core=1 to the command line, and all the libraries will have .ycr files generated along with the .hi and .hbc files. If you are compiling an individual file, then add the yhc -corep flag, and it will generate a .ycr file.

The .ycr files are stored in Binary, but thats OK, because if you want to view one, its literally as simple as:

import Yhc.Core
showFile x :: FilePath -> String
showFile x = loadCore x >>= return . show

(There will be a flag/program/command to view a .ycr file at some point - its not hard to do, but it is hard to figure out where the flag should go and what it should be called!)

Now once you've got Core, what can you do? Take a look at the data structure in the Yhc.Core.Type file, to see what it contains. There are already two programs that depend on Yhc.Core, Catch and Dr Haskell. In particular if you take a look at the main file of Dr Haskell, you can see some trivial ways to play with Core.

Hopefully Yhc.Core will be useful for many projects - if it interests you please drop an email to yhc -AT- haskell.org, saying what you want to do etc. (Of course, you don't have to, but we're curious folk!)

0 Comments:

Post a Comment

<< Home