Closed georgefst closed 4 years ago
@georgefst Yeah, this sounds good to me!
You'll have to look through the logic in src/Text/Pretty/Simple/Internal/OutputPrinter.hs
to see if there is an easy place to indent every line.
Although, I also agree that doing this after #25 would probably be much easier, so if you are interested in implementing #25 first, please go ahead.
I'm starting to think that using prettyprinter
may be the cleaner solution, as discussed in that thread. So I think I'll experiment with that, if you approve.
Obviously that's a fairly sizeable change - how good is the test coverage?
Yeah, I agree that using another package to help with outputting would be a good idea.
I don't really know the various choices, but it sounds like prettyprinter
works well, so I'd be interested in seeing a solution using that (or even another library if you decide there is a better one).
how good is the test coverage?
The test coverage is okay-ish.
There are tests in src/Text/Pretty/Simple/Internal/OutputPrinter.hs
that you saw, as well as a bunch of examples at the bottom of src/Text/Pretty/Simple.hs
. Feel free to add more tests to make this task easier.
prettyprinter
is more or less the de facto standard (it's certainly very widely used), so I think I'll stick with that.
@georgefst BTW, if you find any difficulties in using prettyprinter
, please do report them on the issue tracker. I'm quite keen on making it easier to adopt and easier to use.
I've often found myself wanting to indent a pretty-printed expression in it's entirety, e.g. when surrounding it by other text, as part of an error output.
Would you accept a PR that added an
outputOptionsInitialIndent
field (feel free to bikeshed the name) toOutputOptions
?I haven't yet looked at the code, but I imagine #25 would make this very easy, if it isn't already, as it would just amount to running with a non-zero in the initial state.