wrote a blogpost about using Haskell's laziness to implement a single-pass layout algorithm: https://jaspervdj.be/posts/2023-07-22-lazy-layout.html
It uses an old idea called circular programming or "repmin" introduced in 1984.
Mastodon is the best way to keep up with what's happening.
Follow anyone across the fediverse and see it all in chronological order. No algorithms, ads, or clickbait in sight.