[Haskell-cafe] Writing a compiler in Hakell
lrpalmer at gmail.com
Wed May 6 02:31:40 EDT 2009
On Wed, May 6, 2009 at 12:07 AM, Rouan van Dalen <rvdalen at yahoo.co.uk>wrote:
> Hi everyone.
> I am designing my own programming language.
> I would like to know what is the best way to go about writing my compiler
> in haskell.
> What are the tools available in haskell that can help with compiler
> I know about Happy. Is that a good tool to use?
I don't like Happy. Using a parser generator is like admitting defeat,
when we have no defeat to admit. I would recommend a parser combinator
library like Parsec (or if you like building things from the ground up,
> The compiler is intended for serious use and I would like it to be very
> efficient, maybe competing
with compilers written in C. It should also be very easy to extend as the
> languoge grows.
I agree with minh thu; there are too many questions to consider before
giving too much specific advice.
But in almost all cases, plan on the production version of your compiler
being written in the language it is compiling. This has many advantages.
> Are there any good books that you can recommend on compiler construction in
> general and specific to haskell?
> On another note, how is the operator + implemented in haskell?
> is there a primitve (say #+) that is wrapped by the haskell operator +?
> Maybe something like:
> (+) :: a -> a -> a
> v1 + v2 = #+ v1 v2
It varies from compiler to compiler, but in general, yes. And in GHC I
think it is called +#, actually, but you need to do some digging to find it,
and your code won't be portable once you do.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe