Shelter in the Forest [weekly-2025-04-21]
- April 21, 2025
- Patrick Ferris
I spent much of this week working on Shelter and things related to it. Some of that time was also spent on Forester.
Forester
- April 21, 2025
- Patrick Ferris
I added two important quality-of-life features to my frontend to Forester this week.
Bibtex Support
- April 21, 2025
- Patrick Ferris
I had previously mentioned adding support to Forester for Markdown. This week I added support for Bibtex too. From any *.bib file in your forest, Forester will now dutifully recognise it as a Bibtex file and convert, as best it can, all the entries into Reference trees.
I'm becoming quite convinced of this model at the moment. I'm using Forester's Code.t as a target representation. In fact, to ease the process, I really shouldn't spend all my time on my website, I have reused my Yaml.t -> Code.t and Markdown.t -> Code.t functions in the Bibtex parser.
To see it in action, you could have a look at the Build Systems à la Carte paper which is generated completely from Bibtex.
Full Heading Support
- April 21, 2025
- Patrick Ferris
The eagled-eyed viewer may have noticed that the table of contents for this page has more than one level. I finally caved and spent an evening rejigging my Cmarkit.Doc.t -> Tree code which was hacky and broken and is now less hacky and less broken.
In addition, headings support links and emphasis etc.
Lunch with Jon Sterling
- April 21, 2025
- Patrick Ferris
I had a delightful lunch with Jon Sterling discussing the future of Forester, the nature of the Web (old and new) and the success posting weekly updates for our colleagues. Thanks Jon.
Shelter Fixes
- April 21, 2025
- Patrick Ferris
I spent a good chunk of my week fixing bugs in Shelter with the aim to perhaps setup a VM somewhere and let people kick the tyres of what we've got so far.
The first bug is pretty annoying. At the moment, our filsystem backend is ZFS and we make heavy use of snapshots and cloning in order to provide time-travelling capabilities. Unfortunately, ZFS will take a snapshot before data has fully made it to disk (or whatever is the equivalent point it should reach in ZFS). Commands that generated lots of disk activity would be snapshotted in a half finished state and this would cause all sorts of problems. Thanks to Mark Elvers for the pointer to how OBuilder uses ZFS for the OCaml macOS builders which unmount datasets immediately therefore inducing a flush of sorts. Shelter now follows a similar model with all of the slow downs that create. Anil and I discussed some amalgamation of overlayfs, tmpfs and ZFS to alleviate some of this but for now that's a premature optimisation.
A small eDSL for Shelter
- April 21, 2025
- Patrick Ferris
Whilst testing Shelter, I ended up wanting a way to programmatically invoke the different run commands. This is similar to say a Dockerfile, but maybe with a little more expressivity.
This lead me to revisit the Build systems à la Carte paper and rediscover selective applicative functors.
I started playing around with a selective applicative interface to Shelter, this would allow you to express your dependencies statically but select them dynamically (as the paper says).
module D = Shl (Identity)
let shelterfile =
let open D in
let base_image = from "alpine" in
let is_node_lst img = String.equal "v22.15.0" (stdout img) in
let cmds base =
let node_version = run "node --version" base in
Select.if'
(Select.map ~f:is_node_lst node_version)
(run "node -e 'console.log('success!')")
(run "node -e 'console.log('failure!')")
base
in
with_session "node" (cmds base_image)
From this, we get a slightly more expressive way to describe images.
Geocaml TIFF Library
- April 21, 2025
- Patrick Ferris
I was pleasantly surprised to receive a pull request from Michael adding support to ocaml-tiff for reading TIFF files compressed using LZW. I was also surprised to hear the TIFF LZW is a little different to others.
In trying to get this PR merged, I moved the initialisation of the Eio eventloop to outside each individual test case. This one change then completely broke the entire test suite. After a period of debugging and help from Thomas Leonard the root cause was OCaml's OUnit2 library using process-level parallelism (via Unix.fork), sharing the ring between the parent and the child lead to the issues.
Part II Students
- April 21, 2025
- Patrick Ferris
As the new term begins, it signals that there are only just over two weeks for the final year undegrads at Cambridge to submit their dissertations.
The four students that I help supervise have been sending me drafts of their work (and reminder you can read about their projects) and I'm very impressed. I'm sure the next two weeks will be stressful, but I'm proud of what they have accomplished over the past academic year.