[Haskell-cafe] Writing a compiler in Hakell
florbitous at gmail.com
Wed May 6 04:02:45 EDT 2009
2009/5/6 Rouan van Dalen <rvdalen at yahoo.co.uk>
> I know about Happy. Is that a good tool to use?
Alex and Happy are used in (at least) these two packages:
You should be able to find lots of useful code to start with in both of those.
You can get good performance out of Alex and Happy. Of course there
are more considerations than just performance, and you will get
different opinions about those other aspects. I wrote the python
parser above and I was quite pleased with Alex and Happy from a
LLVM is a nice framework for building the backend of a compiler, and
the Haskell bindings are quite useful:
The amount of work you have to do depends on your runtime system (GC,
threads, exceptions etc). If your language has fairly conventional
semantics (a typical imperative language) then you can reuse a lot of
the existing infrastructure that LLVM provides.
> On another note, how is the operator + implemented in haskell?
It is good to differentiate Haskell "the language specification" from
compilers (and other tools) which implement it. The language
specification does not say exactly how the primitive operations should
be implemented; that is a detail which is up to the compiler writer to
GHC's implementation is the best documented, and there are many
research papers which describe aspects of it (some outdated). For
numerical primitives, you could start by looking at this paper:
"Unboxed values as first class citizens in a non-strict functional
language" Peyton Jones and Launchbury.
More information about the Haskell-Cafe