Day 57: GADTs and Hualian

autrijus on 2005-03-30T02:09:07

(Network outage prevented this journal from being posted on time; sorry)

Today was a short day for me; the first 5 hours are spent on travelling to Hualian, then the post-conference fatigue kicked in right after dinner, so I took a nap, woke up to write this journal, and about to sleep again.

However, I did spend some time playing with GADTs, for the upcoming IMC compiler and Eval.hs refactoring. It is a very powerful feature introduced in GHC 6.4, along with Software Transactional Memory (lock-free, composable, atomic threaded code) and Template Haskell v2 (which allows for type-safe BEGIN blocks in Haskell code that can lexically rebind the builtins based on console input -- extremely Perl6ish).

What are GADTs good for? Well, In most ASTs, it is possible to construct a "nonsense" AST that would not be detected until the runtime. For example, here is a valid Pugs AST:

    # Representing the nonsense program: ++[42=]
    Syn "[]" [ App "&infix:++" [] [] ] [ Syn "=" [ Val (VInt 42) ]
Furthermore, the compiler and evaluator spent lots of dead code on unpacking this Exp structure and repacking them into the Val structure. GADTs solve all this by give each node in AST a well-typed representation, so it becomes impossible to construct invalid ASTs, which greatly simplifies the compiler and evaluator. More details are available in the Wobbly Types paper, and the upcoming Pugs Apocryphon 2: Architecture.

Hualian is evidently a great place for hacking. clkao and obra worked tirelessly on getting svk 1.0rc1 out, with a huge list of changes. svk was the reason why Pugs can adopt a wiki-style development model, and I owe a lot of my productivity to svk. Hopefully one day Pugs can pay back by freeing clkao from the Swig/XS mess, and put an end of this written in Perl, so gets no respect situation.

In other Hualian news, mugwump and ingy worked on Perldoc, their new name for the unified framework that includes POD, Kwid and other inline DOM structures. Magically they managed to agree with each other, producing a detailed process flow document, as well as a comprehensive set of modules for the Perldoc toolchain. Excellent work!

Oh, and mugwump continued to make sense out of the Perl 6 OO model. I love his comments in Class.hs, e.g.:

∃ MetaCategory C₁, C₂ : C₁.catPair = C₂ ∧ C₁.catIsComposite
→ ¬(C₂.catIsComposite)

Other developments from across the world:

  • stevan discovered a bug with IO in loops, when working on his excellent Pod::Streamer module. He also wrote a README explaining his plan on hacking our way out of the Stone Age.
  • vladtz submitted TODO tests for unpacking in subroutine signatures.
  • corion added tests for pugs -I, and noticed that ~~ was broken when the right hand side is a variable; I fixed it promptly.
  • fayland committed POD.t to test for the %POD directive.
  • kcwu added tests for **, Inf and NaN.
  • darren synced SQL::Routine and Locale::KeyedText with their Perl 5 counterparts on CPAN. Side-to-side comparison of p5 and p6 code is a really nice way to learn and appreciate Perl 6!
  • scw, gaal and rgs hacked on perl6.vim, bringing it up to speed with today's Perl 6.
  • bsmith and corion worked on the tentatively named %?CONFIG hash, and hacked in support for pugs -V:foo.
  • gaal began a Perl 6 port of Cache::Memcached.
  • nothingmuch worked some more on tests, graphs, and the beautiful testgraph.pl.

That's it for today. See you tomorrow!