Posts tagged Racket

Racket Makefiles

:: Racket

A few years ago I wrote about makefiles for Racket. Some things have changed.

  1. The old makefile built and pushed documentation to a GitHub Pages branch of the repo. That’s no longer necessary: The Racket package catalog builds and hosts documentation.

  2. The Racket package catalog puts a yellow badge of shame on packages with missing dependencies (deps and build-deps in the package’s info.rkt). I want the makefile to check this.

  3. In .travis.yml files for Travis CI, I think the script section ought to simply invoke targets in the makefile — delegating details to the latter.

  4. Likewise some details needn’t even be in the makefile — they can move to the collection’s info.rkt. Example: The list of directories to clean.

  5. The old makefile had separate PACKAGENAME and COLLECTS variables; for single-collection packages they were the same value. I wanted to simplify this to just the package name and use the appropriate package variants of raco commands.

In that spirit, here’s an updated Makefile, which I recently started using in the rackjure, markdown, and frog projects.

Please scroll

:: Racket, Emacs

Recently I got more time to catch up on racket-mode. I improved two things that happen to fit one theme — an extraordinarily advanced UX concept I call, “scrolling down to the point of interest.”

At-expressions

:: Racket, racket-cookbook

If you’ve heard of Racket “at-expressions”, maybe you think they’re “that funny Scribble notation in which you write Racket documentation.”

In fact at-expressions are a general, alternative way to write s-expressions. They can be used in various handy ways.

Let’s look at using at-expressions for a few practical things like:

  • “string interpolation”
  • regular expressions
  • “here” strings

GitHub dropped Pygments

:: Racket, software

My first-ever open source contribution, a couple years ago, was to a project called Pygments. My motivation? GitHub was displaying Racket source code poorly. Pygments didn’t have a Racket lexer. GitHub was using a Scheme lexer for Racket code. The Scheme lexer was highlighting square brackets in red as an “error”. This was really distracting and ugly.

I contributed a new Racket lexer to Pygments, and waited for that to roll into a Pygments release and in turn be deployed on GitHub. Finally Racket code looked good! Later Dave Corbett substantially improved the Racket lexer beyond my small start.

A few days ago, I was confused to see that Racket code was displaying poorly again on GitHub. The square brackets were highlighted in red as errors — again??

Cartoon-me’s thought balloons: WAT, OMFG, FML, &c. Why are we going in circles?

Racket workflow

:: Racket

If you’re coming to Racket from another REPL language (such as another Lisp), this post might be real Captain Obvious material.

But if you’re coming to Racket from an edit/compile/debug language like C or C++, it might be unclear what a typical workflow is. You might have questions like:

  • How do I compile?
  • How do I debug?

Why macros?

:: Racket, Clojure, Hacker School

Yesterday a couple people asked me, “How and why do you use macros in a Lisp like Racket or Clojure?”.

I gave answers like:

  • The compiler can do a search-and-replace on your code.

  • You can make DSLs.

  • They’re an “API for the compiler”.

Although all true, I wasn’t sure I was getting the full idea across.

Written in Racket

:: Racket

This is an overview of things I’ve created using Racket. Two motivations for writing this now:

  1. Over the last week I was at three conferences (whew!) where, when meeting or catching up with someone, I had to explain what I’ve been doing. I mentioned my current projects or projects I guessed they’d relate to. But that’s not necessarily representative of all that I’ve been able to do with Racket. I wish I’d been able to give a better overview. I have quite a few repos on GitHub, but that’s just a big list with no structure.

  2. In about a week I start my batch at Hacker School. I’ll likely spend less time with Racket, because the whole point is to learn new things. Now is a good time to take inventory. And I’ll be better prepared to talk about Racket there.

As a result, here’s an inventory, grouped into categories.

Destructuring lists with match

:: Racket

Let’s say you need to destructure a list with match, using a pattern that specifies a “rest” or “more” element. Be careful. You probably want to use list* not list.

Does your Racket project need a makefile?

:: Racket, racket-cookbook

NOTE: See my newer post.

Most of my Racket projects don’t use a makefile. Why would they? raco make or raco setup suffices.

But a makefile can consistently define some common project tasks. And it can really help when you want to generate HTML documentation from Scribble sources, and publish it to GitHub Pages using the automagical gh-pages branch.1