quchen / prettyprinter

A modern, extensible and well-documented prettyprinter.
BSD 2-Clause "Simplified" License
293 stars 34 forks source link

Example code is broken #251

Open BatiDyDx opened 6 months ago

BatiDyDx commented 6 months ago

The example shown on the module main page, the prettyprintType function, is actually not type checking due to the String list of separators. It is rather expected a [Doc ann] type element.

quchen commented 4 months ago

Did you enable OverloadedStrings? It’s what allows using String literals directly as Doc ann directly.

georgefst commented 10 hours ago

It might be nice if the example mentioned OverloadedStrings. Plus the imports needed: not just Prettyprinter, but also Prettyprinter.Util. These things won't be obvious to beginners.

Another thing I've just noticed, while adapting the example, is that the example only works in GHCI due to ExtendedDefaultRules, and thus doesn't work straight away when copied in to a source file.

georgefst commented 10 hours ago

It might be nice if the example mentioned OverloadedStrings. Plus the imports needed: not just Prettyprinter, but also Prettyprinter.Util. These things won't be obvious to beginners.

Ha, I'm not the first to say this: https://github.com/quchen/prettyprinter/issues/209#issuecomment-966483759. Perhaps this issue should be closed in favour of that one.