david-christiansen / final-pretty-printer Goto Github PK
View Code? Open in Web Editor NEWA monadic (and pretty) pretty printer for Haskell
License: MIT License
A monadic (and pretty) pretty printer for Haskell
License: MIT License
Using Stack with LTS-15.15 and GHC 8.8.3, I had to use allow-newer
to build final-pretty-printer
. Perhaps relax the upper bounds?
WARNING: Ignoring final-pretty-printer's bounds on ansi-terminal (==0.6.*); using ansi-terminal-0.10.3.
Reason: allow-newer enabled.
WARNING: Ignoring final-pretty-printer's bounds on base (>=4.3 && <4.10); using base-4.13.0.0.
Reason: allow-newer enabled.
WARNING: Ignoring final-pretty-printer's bounds on containers (==0.5.*); using containers-0.6.2.1.
Reason: allow-newer enabled.
WARNING: Ignoring final-pretty-printer's bounds on exceptions (==0.8.*); using exceptions-0.10.4.
Reason: allow-newer enabled.
We were debugging an issue with the SML version of final-pretty-printer
and came across what may be a logic error in the chunk
algorithm.
In short, there is the following code which determines whether to raise a fault:
w <- measureCurLine
n <- askNesting
when (n + w > wmax) empty
when (w > rmax) empty
Observe that when nesting is enacted (through newline
), spaces of the appropriate width are added to the current line (using chunk
). So, in this part of chunk
, it looks like this whitespace is counted twice: first in the size of the current line w
, and second in the nesting n
. Concretely, this results in code being too aggressively broken, when there is sufficient width for it to remain flat.
We believe that this code can be changed to the following:
w <- measureCurLine
n <- askNesting
when (w > wmax) empty
when (w - n > rmax) empty
We have tried this change out in our SML port, and it appears to give the correct result. What do you think?
--- @jonsterling and @cangiuli
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.