quchen / prettyprinter

A modern, extensible and well-documented prettyprinter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stack machine is unnecessarily opaque

georgefst opened this issue · comments

Perhaps it's specific to my use case, but Render.Util.StackMachine.renderSimplyDecorated seems like it would be more useful if it actually passed the current stack to the first argument (the text function).

I've found myself using renderSimplyDecoratedA with a State that just reimplements the stack. This feels quite silly.

I'm not very familiar with this part of the code. If you have a change in mind, could you simply submit it as a PR? That should simplify the discussion.

Done.

For a use case, see here, where I am already using the modified form as renderSimplyDecorated'.

Perhaps it's specific to my use case

Actually, it kind of is. And there's a better approach I could take anyway.

And there's a better approach I could take anyway.

I'm curious about this, so I've started watching https://github.com/georgefst/prettyprinter-graphviz for now. :)

I'm curious about this

Basically, by using the whole annotation stack to render each substring, I'm neglecting the fact that the graphviz labels use a HTML-esque tree structure, so I should really be able to handle the annotations one at a time as they're pushed and popped. This would be more elegant and result in more concise outputs in general.

It might not currently be possible to do that with the current Haskell graphviz library, so I may need to make changes over there. Admittedly, it's not much of a priority for me, since prettyprinter-graphviz is otherwise essentially complete, and AFAIK nobody's using it, except me in one project at work.

So you'll probably get a notification some time next year once you've forgotten why you were ever watching it in the first place.