Skip to content

Conversation

@jordwalke
Copy link
Member

@jordwalke jordwalke commented Dec 6, 2022

This demonstrates how to achieve prettier printing of function calls. Sending a PR just for discussion. It is based on a really old commit of Reason, but shouldn't be too hard to rebase and fix the regressions.
Instead of:

let x =
  reallyLongFunction(
    arg,
    arg,
  );

It will print:

let x = reallyLongFunction(
  arg,
  arg,
);

In its current state it also applies the same convention to other constructs which should not be wrapped in that manner - it's just a matter of going through and telling the printer which style to use in each case.
I included some test output changes which demonstrate both some improvements and some regressions in printing.

type variant =
| X(int, int) /* End of line on X */
| Y(int, int); /* End of line on Y */ /* Comment on entire type def for variant */
type variant = | X(int, int) /* End of line on X */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a regression obviously.

n + tmp;
| None => 20
};
let result = switch (None) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right idea.

| Y(_) => "result of Y" /* End of arrow and Y line */
};

type optionalTuple = | OptTup(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression

),
),
);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right idea below

1, /*eol1*/
2 /* eol2 */
);
let y = TwoArgsConstructor(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right idea below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant