Keep the header of a let with locally abstract types on one line
Why
A binding annotated with type a. was printed as one group, so a line break in its body, such as a switch, broke the header after : and = as well and indented the body twice. This is how every function over a GADT is written. The header now stays on one line when its first line fits, as for other annotated bindings.
modifiedFormat let with locally abstract types
let rec eval: type a. expr<a> => a = e => switch e { | Int(n) => n | Bool(b) => b }
rescript
Before
After
let rec eval: type a. expr<a> => a = e => switch e { | Int(n) => n | Bool(b) => b }let rec eval: type a. expr<a> => a = e => switch e { | Int(n) => n | Bool(b) => b }
Review
- What happens to a header that doesn't fit? It is printed as before, broken after
:and=; the printer fixture keeps such a case, also with attributes in front, which stay outside the layout choice so that the header's width is measured from thelet.