[ANN] threading 2.0

Some of you may be familiar with my threading package, which is a port of Clojure’s threading macros to Racket. The package is quite simple and has been essentially unchanged since I initially released it in 2015.

In the nine years I’ve been using it, there have been a handful of small tweaks I’ve wanted to make and helper forms I’ve found myself regularly writing. This week, I finally bothered to incorporate those changes into the package itself. The new version should be entirely backwards compatible, but it comes with several improvements and minor changes:

  • ~> has been made slightly more flexible: it allows the threaded form to be threaded into function position in a function application. That is, (~> f (_ x)) is now legal.

  • when~>, unless~>, and cond~> have been added, which allow portions of a pipeline to be conditionally executed. (I’ve found these to be particularly helpful when staging slides in #lang slideshow.)

  • tee~> has been added, which allows splitting a pipeline similarly to the way the Unix tee utility does.

  • The package documentation has been expanded and largely rewritten.

  • Many forms have been deprecated, mainly ~>> and its variants. They are still provided for backwards compatibility (and probably always will be), but I just haven’t found them useful enough to warrant continuing to provide ~>> variants of every operator when ~> can be used with _ to the same effect.

The latest documentation is available here, and it should also be available on the package server once docs are rebuilt. Feedback is welcome. If you find any breakage I’ve overlooked, please open a bug report.

10 Likes