Skip to content

Ribbons and variable-width documents #88

@thomashoneyman

Description

@thomashoneyman

Wadler's original paper includes support for a "ribbon" width, which is additional width given to the document to allow extra space for indented lines. For example, with a width: 40 for the document, and a tab size of 4 spaces, then a function which is indented 5 levels (20 spaces) will have only 20 remaining characters of width to play with.

https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf

The point of the ribbon is to give additional spacing to lines proportional to their indentation level; with a ribbon fraction of 0.5, for example, the 20-space-indented function line can have up to a width: 50 (40 + (0.5 * 20)).

I'd like to make use of this in a code formatter I'm writing, but alas haven't seen where I could hook into widths on a line-by-line basis. Is ribbon support something you are interested in providing as part of the library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions