Racket ships with racket/generic
, a system for defining generic methods, functions that work differently depending on what sort of value they are supplied. I have made heavy use of this feature in my collections library, and it has worked well for my needs, but that system does have a bit of a limitation: it only supports single dispatch. Method implementations may only be chosen based on a single argument, so multiple dispatch is impossible.
Macros are one of Racket’s flagship features, and its macro system really is state of the art. Of course, it can sometimes be difficult to demonstrate why macros are so highly esteemed, in part because it can be hard to find self-contained examples of using macros in practice. Of course, one thing that macros are perfect for is filling a “hole” in the language by introducing a feature a language lacks, and one of those features in Typed Racket is ADTs.
Elm is a wonderful language for building web apps, and I love so much of its approach to language design. Elm does so many things right straight out of the box, and that’s a real breath of fresh air in the intersection of functional programming and web development. Still, it gets one thing wrong, and unfortunately, that one thing is incredibly important. Elm took the “functions” out of “functional record types”.
Modern web applications are often built as single-page apps, which are great for keeping concerns separated, but problematic when tested. Logic needs to be duplicated in front- and back-end test suites, and if the two apps diverge, the tests won’t catch the failure. I haven’t found a very good solution to this problem aside from brittle, end-to-end integration tests.
To attempt to address a fraction of this problem, I built factory_girl_api, a way to share context setup between both sides of the application.
Application configuration can be a pain. Modern web apps don’t live on dedicated boxes, they run on VPSes somewhere in the amorphous “cloud”, and keeping configuration out of your application’s repository can seem like more trouble than it’s worth. Fortunately, The Twelve-Factor App provides a set of standards for keeping web apps sane, and one of those guidelines advises keeping configuration in the environment.
Envy is the declarative bridge between Racket code and the outside world of the environment.
Heroku is a “platform as a service” that provides an incredibly simple way to deploy simple internet applications, and I take liberal advantage of its free tier for testing out simple applications. It has support for a variety of languages built-in, but Racket is not currently among them. Fortunately, Heroku provides an interface for adding custom build processes for arbitrary types of applications, called “buildpacks”. I’ve built one for Racket apps, and with just a little bit of configuration, it’s possible to get a Racket webserver running on Heroku.
So, I have a blog now. It’s a simple static blog, but what’s unique about it is that it’s powered by Racket; specifically, it uses Greg Hendershott’s fantastic Frog tool. I’ve taken this and moulded it to my tastes to build my blog, including configuring automatic deployment via Travis CI, so my blog is always up-to-date.