Re: Writing Compilers in Functional Languages

Alain Cremieux <alcremi@pobox.com>
3 May 2005 20:48:38 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: Writing Compilers in Functional Languages arthurvl+news@cs.uu.nl (Arthur van Leeuwen) (2005-04-28)
Re: Writing Compilers in Functional Languages tarvydas@allstream.net (Paul Tarvydas) (2005-04-28)
Re: Writing Compilers in Functional Languages neelk@cs.cmu.edu (Neelakantan Krishnaswami) (2005-04-28)
Re: Writing Compilers in Functional Languages awwaiid@thelackthereof.org (Brock) (2005-04-28)
Re: Writing Compilers in Functional Languages torbenm@diku.dk (2005-04-30)
Re: Writing Compilers in Functional Languages neelk@cs.cmu.edu (Neelakantan Krishnaswami) (2005-05-02)
Re: Writing Compilers in Functional Languages alcremi@pobox.com (Alain Cremieux) (2005-05-03)
Re: Writing Compilers in Functional Languages YRassokhin@luxoft.com (2005-05-05)
Re: Writing Compilers in Functional Languages ali@olympe.ch (Ali Al-Shabibi) (2005-05-13)
| List of all articles for this month |

From: Alain Cremieux <alcremi@pobox.com>
Newsgroups: comp.compilers
Date: 3 May 2005 20:48:38 -0400
Organization: les newsgroups par Wanadoo
References: 05-04-068 05-04-084 05-04-098 05-05-015
Keywords: functional
Posted-Date: 03 May 2005 20:48:38 EDT

Neelakantan Krishnaswami wrote:
>>I not sure about this. Appel's book uses updatable references in many
>>places, such as for name generation and hash tables. These are not
>>easily translated into Haskell. The same is true for exceptions.
>>Additionally, though SML and Haskell are both functional languages,
>>the "traditional" programming style for these is quite different - you
>>would tend to use type classes, list comprehensions and monads in
>>Haskell, and these are not found in SML. So translating a program
>>directly from SML to Haskell will not be trivial and the result will
>>be very atypical Haskell.
>
> This is a good point, and I'm changing my mind.
>
> When I read Appel's book, I was already decent at functional
> programming, and I translated on the fly from his imperative style to
> a pure style (using state passing style in ML). But if Kkaa wants to
> write a compiler to learn Haskell, then this advice won't work.


If it is of any interest to you, I am precisely working on porting
ML/OCaml code concerning this book to Haskell. You can see a brief
summary of this here :
http://www.haskell.org/communities/11-2004/html/report.html ( 8.4)


Porting code is quite a bit of work, but not so much as what has been
said. I have partly suppressed the side-effects used by Appel, partly
translated them using the ST monad, which is quite straightforward in
fact. The resulting code works (that's the nice part of a port, no
extended testing is necessary), and is absolutely not atypical
Haskell. ML and especially OCaml are closer to Haskell that what I
thought at the beginning (but the port took me more time than I
thought -- but this is always true in C.S. ). Code available if you
like (and helping hand appreciated, because it is far from complete).


Alain



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.