I'm quite impressed by (and a bit proud of!) the number of bugs that has been revealed through `dhall`'s usage of `prettyprinter`! I wonder how `prettyprinter` could rely less on the users to discover these bugs though. In particular I wonder whether property tests could help – IMHO they've been quite effective in [`dhall`](https://github.com/dhall-lang/dhall-haskell/blob/e931451a2b2892fa373c9dfc94b31bcd764131be/dhall/tests/Dhall/Test/QuickCheck.hs#L496-L547)! For example I believe that the recent bugs could have been discovered by tests for the following properties: * https://github.com/quchen/prettyprinter/issues/91: The result of applying `layout{Pretty,Smart} opts . group` to a `Doc` that doesn't contain `Fail`, should never contain `SFail`. * For `removeTrailingWhitespace`: * The (rendered) input and output should only differ by trailing spaces. * The output should never contain trailing spaces. * `removeTrailingWhitespace` is idempotent. It's probably more difficult to come up with properties that would reveal unknown bugs, but it might be worth trying!
I'm quite impressed by (and a bit proud of!) the number of bugs that has been revealed through
dhall's usage ofprettyprinter!I wonder how
prettyprintercould rely less on the users to discover these bugs though.In particular I wonder whether property tests could help – IMHO they've been quite effective in
dhall!For example I believe that the recent bugs could have been discovered by tests for the following properties:
grouped Line fails #91: The result of applyinglayout{Pretty,Smart} opts . groupto aDocthat doesn't containFail, should never containSFail.removeTrailingWhitespace:removeTrailingWhitespaceis idempotent.It's probably more difficult to come up with properties that would reveal unknown bugs, but it might be worth trying!