Day 244: Hacking GHC.

autrijus on 2005-09-29T21:39:34

Continuing yesterday's work, today I got seriously addicted in GHC core hackery, skipping the entire Curry workshop. It was a real pleasure pairing with spj on this. He reminded me of lwall -- both have an obsession on providing useful feedback to programmer, strong intuition on how language features intersect, and above all a deep enthusiasm to their respective languages.

Thanks to spj's continuous guidance, I hacked in support for existential record types on both vanilla and GADT types, which allows us to write:

data Counter public = forall this. New
    { self   :: this
    , inc    :: this -> this
    , output :: this -> IO ()
    , tag    :: public
    }
The tag function is well-typed as Counter public -> public; the other three fields hides the real implementation from the Counter data type, so one can have a counter using Int, another using String, and have both be of the same type.

This representation is quite close to how encapsulation works in OO langauges, and the feedback from #haskell has been very positive. Additionally, the soundness of the GADT/Labels treatment passed scrunity by Oleg today, which made me feel much safer.

Of course, any attempt to use the three private fields as normal functions raises a compile-time error that advises the use of pattern-matching syntax instead. Also, in the GADT form, the forall this may be omitted to improve readability.

While I was madly hacking away, brendan passed by, and graciously accepted a Pugs T-Shirt from me. We talked about many things -- I'm very excited to hear that they are considering to adopt Rhino's continuation engine for SpiderMonkey (which will make Perl6-on-JavaScript insanely faster), and that the XUL scripting is proceeding well. They would like to use user's system python/perl/ruby/etc if possible, but that complicates the versioning problem.

Inevitably, the topic of shared runtime came up, and it seems that Mono's RAND patent position is still not yet very satisfatory. Parrot has matured a bit since two years ago when brendan checked it out, so I filled him on some recent development. With 0.3.0 out in a couple days, we can finally start targetting Parrot again -- hopefully the long wait will be proven worthwhile.

Oh, do check out geoffb's writeup of his musings on #perl6; it's a nice survey of some of the good ideas from other language that are finding their way into Perl6.

After yesterday's discovery of ILX codegen, spj pointed out that there is a more robust Java codegen on the same directory. Targetting JVM suddenly looks more attractive too...

All in all, I think my time on hacking GHC core is well-spent; I learned a lot of Haskell idioms that should make Pugs code cleaner (such as the case x of DataCon {} -> ... syntax that works even on non-record types), and about complexity management of a large real-world language implementation -- i.e., what makes it to evolve extremely fast, despite a relatively small core team and contributor base, and an utterly broken issue-tracking system. RT-powered bugs.haskell.org seems like a good idea...

Tomorrow is the Haskell workshop, the final day and highlight of this conference. See you!


curry workshop

nicholas on 2005-09-29T22:57:25

skipping the entire Curry workshop

Of course, if you are able to make it to YAPC::EU::2006 in Birmingham I'm sure it will be possible to have a curry workshop[*]. And a balti workshop. And maybe some others :-)

* tornadoes and earthquakes permitting

*perks up*

jesse on 2005-09-30T02:08:57

How can I help with bugs.haskell.org