Hello, YOCaml
This blog is generated by YOCaml, a static site generator written in OCaml. Unlike most generators, YOCaml is not a command line tool you configure — it is a library you use to write your own generator.
The idea
A YOCaml site is an OCaml program. In it you describe rules: "for every Markdown file
under content/articles, apply this template and write the result into _site/posts/".
Each rule is an arrow, in the Arrow type class sense, and arrows compose. The whole
transformation pipeline is therefore explicit and type checked.
Why it is interesting
Three reasons, from where I stand:
- Incremental builds come for free. YOCaml tracks the dependencies of every target — source files, templates, and the generator binary itself — and only regenerates what actually changed.
- Metadata is typed. An article's front matter is validated as it is read, through a dedicated validation module. A malformed date or a missing required field fails the build rather than quietly producing a broken page.
- Effects are abstract. The core of YOCaml does not know how to read a file. Runtimes
(
yocaml_unix,yocaml_eio,yocaml_git, …) supply the effects. That is how the same generator can write straight into a Git repository instead of the filesystem.
What comes next
I will write here about OCaml, type systems, and the tools I build. The source of this site lives on GitHub.
Comments