Over the past two years, the PDF version of Bartosz Milewski’s Category Theory for Programmers became a highly-successful open-source book, which was adapted to other programming languages, such as Scala and OCaml. Unfortunately, building this 400+ page PDF from LaTeX sources in multiple editions took a significant amount of time, sometimes upwards of 15 minutes. One of the reasons was, all the code snippets are loaded from external code files (so that they can be easily adapted to other programming languages), and they have to be compiled each time in a format LaTeX understands.
I recently explored some possibilities to reduce the time it takes for the snippets to build, and I’m happy to report the results: a 60% improvement overall! Big thanks to muzimuzhi from the minted github, who generously helped me to arrive at the solution below.
Here’s a quick summary of my changes, that resulted in reducing my Travis CI builds from 14-16 minutes to mere 6!