blin

Library Note Pattern

Published:

Every once in a while I need to write a comment in one place and then refer to that comment from other places.

Turns out there is now a language-independent tool that helps to use this pattern - tagref!

tagref claims to be inspired by the Glasgow Haskell Compiler (GHC), and specifically by their “Notes” system described in The Architecture of Open Source Applications specifically chapter 5 section 6.

GHC Style Guide (a) also describes this pattern. Version of the style guide as of 2025-07-18 has exactly the same text as the book mentioned above. See archived link from 2020 for a slightly different phrasing.

The same pattern is also used in the Lean (proof assistant) ecosystem, where it is referred to as “library note”. See the definition of the pattern and the use of the pattern.