[Haskell-cafe] Writing a compiler in Hakell

Sebastiaan Visser sfvisser at cs.uu.nl
Wed May 6 04:52:58 EDT 2009


On May 6, 2009, at 8:07 AM, Rouan van Dalen 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  
> construction?
>
> I know about Happy.  Is that a good tool to use?
>
> 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.
>
> Are there any good books that you can recommend on compiler  
> construction in general and specific to haskell?

What is your goal? Writing a compiler, for fun and educational  
purposes, or to implement a new language?

When the actual language is the main purpose and your language will be  
a functional one you can try to piggyback on existing compilers.

For example, translate your language to the GHC core or UHC[1] core  
and you get a cross platform highly optimizing compiler for free. You  
can now freely focus on the semantics of your language and let an  
existing code generator do the dirty work for you.

When, in the end when your languages is finished, the existing  
compiler is not fast enough, improve it and everyone benefits!

> 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
>
> Thanks in advance
>
> Rouan.


[1] https://svn.cs.uu.nl:12443/repos/EHC/trunk/EHC/src/ehc/Core/AbsSyn.cag

--
Sebastiaan Visser



More information about the Haskell-Cafe mailing list