Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haskell pretty printer (best of class ?) #31

Open
PierreR opened this issue Aug 18, 2015 · 5 comments
Open

Haskell pretty printer (best of class ?) #31

PierreR opened this issue Aug 18, 2015 · 5 comments

Comments

@PierreR
Copy link

PierreR commented Aug 18, 2015

It feels odd to me to have wl-pprint / ansi-wl-pprint as "notable libraries" in a "best of class" section.

I don't think there is a "best of class" pretty printer for Haskell. See this thread:

https://www.reddit.com/r/haskell/comments/32jr3f/new_maintainer_for_wlpprint/

@Gabriella439
Copy link
Owner

I can remove wl-pprint, but I was reasonably certain ansi-wl-pprint was the leader in the pretty-print category (both by downloads and general activity).

@PierreR
Copy link
Author

PierreR commented Aug 21, 2015

Looking at it again, I can see that ekmett is the new maintainer of ansi-wl-pprint. That's good because before that it looks pretty much dead. Still there hasn't been much improvement over the last couple of years.

My main peeve is the fact that the package hijacks <$> or <>. I have never really like using it and have the feeling that Haskell deserves something better in this area. There are wl-pprint-extras, wl-pprint-text and annotated-wl-pprint but I have never tried them.

@Gabriella439
Copy link
Owner

At this point the prettyprinter library is the best-in-class Haskell package here. Marking this as "good first issue" to update the post

@PierreR
Copy link
Author

PierreR commented Jan 23, 2018

On the other hand prettyprinter is not used wildly (yet):
https://packdeps.haskellers.com/reverse/prettyprinter

As an aside I was about to migrate from ansi-wl-pprint to prettyprinter .I have lot's of Pretty instance declarations that assumes color (an AnsiStyle annotation). I guess it is just not possible with prettyprinterto assume color in instance declaration ?

So for instance:

instance Pretty PValue where
  pretty (PBoolean True) = dullmagenta "true"
  pretty (PBoolean False) = dullmagenta "false"
  pretty (PString s) = dullcyan (pretty (stringEscape s))
  pretty (PNumber n) = cyan (pretty (scientific2text n))
  pretty PUndef = dullmagenta "undef"
  pretty (PArray v) = list (map pretty (toList v))

The compiler error is Couldn't match type ‘ann’ with ‘AnsiStyle’

@nponeccop
Copy link
Collaborator

There is also a bias there:

  • you can prettyprint as long as it fits the Wadler-Leijen algorithm (e.g. you can't emulate /bin/column -t with pretty printers which is pretty annoying for newbies)
  • you can parse as long as it's top down parsing - the supply of bottom-up parsers is pretty limited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants