[racket] redex + #lang = awesome

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Mon Oct 22 12:23:59 EDT 2012

Sam and I have been developing a prototype language using redex and 
#lang for about a year now, and that's been a really great experience (I 
don't believe we could have done this research and gotten it right 
without this tool support).

But on my way to OOPSLA I re-implemented some of the core parts of our 
model to try to boil things back to their essential parts.  This 
involved a model for a PCF-like language (ie, simply typed lambda 
calculus + numbers + if0 + some primitive operations).  Because I wanted 
to experiment by writing #lang pcf programs, I just wrote a trivial 
module-begin and top-interaction wrapper to call 
apply-reduction-relation* (LaTeX can't do that!).  This is what Sam and 
I had previously done for our much larger model.

Then I thought, PCF is typed, so let's get compile-time type checking. 
That turned out to be a couple lines of code.  Now as I write PCF 
programs I get real-time feedback of type errors thanks to online check 
syntax.

Then I thought, PCF's binding structure is a lot like Racket's: wouldn't 
it be nice to get syntax coloring, syntax arrows, renaming, etc.  That 
was about another 30 lines of code.

In the end, with very little effort, I was able to whip up a language 
with a static and dynamic semantics written in Redex and then leverage 
much of the DrRacket environment to make programming in those languages 
a much more pleasant experience than plain ol' s-expressions.

All of which is just to say: very cool.  Racket should be considered as 
the tool of choice for discriminating language hackers.

If you'd like to try it out or steal some of the ideas, the code is very 
simple and located here:

    https://github.com/dvanhorn/pcf

If you have Sam's raco git package, you can install with:

    raco git --github dvanhorn pcf

David

Posted on the users mailing list.