1 A set of example programs for handling external core format.
3 In particular, typechecker and interpreter give a precise semantics.
7 ==== Documentation ====
9 Documentation for the External Core format lives under docs/ext-core in the
10 GHC tree. If you are building from HEAD, do not rely on the version of the
11 External Core documentation that lives in haskell.org -- it is obsolete!
15 The checker should work on most programs. Bugs (and infelicities)
18 1. There's some weirdness involving funny character literals. This can
19 be fixed by writing a new lexer for chars rather than using Parsec's
20 built-in charLiteral lexer. But I haven't done that.
22 2. The test driver attempts to find module dependencies automatically,
23 but it's slow. You can turn it off with the "-n" flag to the driver,
24 and specify all dependencies on the command line (you have to include
25 standard library dependencies too.)
26 * It would help to cache dependency info for standard libraries
27 in a file, or something, but that's future work.
29 3. To avoid implementing some of the I/O primitives and foreign calls,
30 I use a gross hack involving replacing certain standard library
31 modules with simplified versions (found under lib/) that depend on
32 fake "primops" that the Core interpreter implements. This makes it
33 difficult (if not impossible) to load optimized versions of standard
34 libraries right now. Fixing this is future work too.
36 Typechecking all the GHC libraries eats about a gig of heap and takes a
37 long time. I blame Parsec. (Someone who was bored, or understood happy
38 better than I do, could update the old happy parser, which is still in the
41 The interpreter is also memory-hungry, but works for small programs
42 that only do simple I/O (e.g., putStrLn is okay; not much more than that)
43 and don't use Doubles or arrays. For example: exp3_8, gen_regexps, queens,
44 primes, rfib, tak, wheel-sieve1, and wheel-sieve2, if modified so as not
45 to take input or arguments.
49 To run the checker and interpreter, you need to generate External Core
50 for all the base, integer and ghc-prim libraries. This can be done by
51 adding "-fext-core" to the GhcLibHcOpts in your build.mk file, then
52 running "make" under libraries/.
54 Then you need to edit Driver.hs and change "baseDir" to point to your GHC
57 Once you've done that, the ext-core library can be built in the usual
59 1. runhaskell Setup.lhs configure
60 2. runhaskell Setup.lhs build
61 3. runhaskell Setup.lhs install
63 Then, you can build the example Driver program with:
64 ghc -package extcore Driver.hs -o Driver
66 And finally, you can use the included Makefile to run tests:
68 make nofibtest (to run the parser/checker on all nofib programs...
70 make libtest (to typecheck all the libraries)
72 Tested with GHC 6.8.2. I make no claims of portability.