Coder Social home page Coder Social logo

final-pretty-printer's People

Contributors

davdar avatar david-christiansen avatar jonsterling avatar ryanglscott avatar tristancacqueray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

final-pretty-printer's Issues

Relax upper bounds on dependencies

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.

Possible logic error in chunk?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.