quchen / prettyprinter

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

Add pattern SString #214

Closed Bodigrim closed 2 years ago

Bodigrim commented 2 years ago

I wonder if this could provide a lightweight resolution to #207, alternative to #208. @newhoggy what do you think?

The idea is to use SString to perform T.pack / T.unpack when on GHC 7.10+ (which covers the vast majority of users) and resort to slow read . show (https://github.com/quchen/prettyprinter/issues/207#issuecomment-928422424) only on older systems.

Bodigrim commented 2 years ago

Actually, the latest incarnation of #208 is pretty lightweight, and this patch is obnoviously CPP-heavy, so dunno if I can claim any improvement ;) Feel free to close, this is just a raw experiment.

sjakobi commented 2 years ago

I don't have any personal experience with using -f-text, but it seems to me that the API enhancements in #208 are more powerful since they also provide ways for using the lazy-Text and Builder based parts of the prettyprinterAPI.

Nevertheless, I'm curious what @newhoggy thinks about this PR.

Bodigrim commented 2 years ago

@sjakobi if you are fine with #208, then it's indeed a more flexible and powerful way forward.