I wasn’t convinced that the exhaustive approach with weigths was a good idea. It makes it computationally super intensive and hard to predict what the printer would do.
Instead prettier runs on a simple idea: if something doesn’t fit in one line, break the outermost parent.
This simple rule (implemented via the Wadler IR) is efficient to implement and makes the output generally look good.
Then the hard part was to go through the very looong (took me ~6 months full time) process of adding special cases for every constructs that human write in a special way.
There is nothing in there that’s hard at a computer science level, it’s just a lot of special cases. I don’t believe that there’s a general solution for it, you just need to slog through it.
And the last annoying thing are comments, they can be everywhere and are super annoying to print correctly.
Overall, it wasn’t really hard, but a lot of work.