fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
758 stars 189 forks source link

[Feature request] Keep `interface end` on a single line #3089

Closed isaacabraham closed 1 month ago

isaacabraham commented 1 month ago

I propose we format single "marker" interfaces on a single line e.g.

type Customer = interface end

The existing way of Fantomas deals with this problem is ...

type Customer =
    interface
    end

Pros and Cons

The advantages of making this adjustment to Fantomas are that the interface / end pattern is common when using e.g. phantom types or otherwise, whereby you may have a list of single marker interfaces used to distinguish one kind of a type from another using generics, and there may be many of them in a file e.g.

type Customer = interface end
type User = interface end
type Office = interface end
type Manager = interface end

The current formatting strategy uses up four lines (including the whitespace line) rather than a single line. More importantly, I think it's much more readable with the single line approach.

etc.

The disadvantages of making this adjustment to Fantomas are that it is extra work.

Examples

See above.

Extra information

I believe that this should be something that has a fairly low cost to identify and format e.g. interfaces with no members?

Estimated cost (XS, S, M, L, XL, XXL): XS / S

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

nojaf commented 1 month ago

Fantomas currently works like this, as noted in our Changelog.

Here's an example:

https://fsprojects.github.io/fantomas-tools/#/fantomas/main?data=N4KABGBEDGD2AmBTSAuKAXAngB0WAwgK4DO6sAtogE5gC8YAlgHbrUBmAhtHok-JABpwUYonTpmAc2KowAbWERQEFVAAkWXLMjN0gxSshqAbhwA2hZGgWrVABiG3DAST690AZQYAvZI6dgACwGEAC6BgC%2B-koh6ppWULr6TkamFgk2AQCM0baQALIcAB4AMsyIJbyS6AAWydkATHax4apRBsp5GjgJkLzwAPJsZUyIHlhmfrGp5paymU4NuaqQAKJ8QyNTAVBmbJAtkbmdK91aaJAARrCwZvWnaXPWsRAAzMsuTKJU6ABizOYAHKIADuZnK91s6ColkObWO0zOvWut0hEBm6XmLyCH3RHmwXEQACFEGxYFREAAFDhUDiUVhUNEqaGwpytFTtVQnQxI7Qou4fDFPeTYgCsuKg%2BMJJLJFJKsBB1GgHFErmMsGVElgTCZEBZiDhHIRKV5F35TKFGWxADYJZApdwZe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mE7vKB4CEOKOOMx5lzop7QmYtroW0egwLYJQ6SXHgBwbMsBcpMEkLXPmR8ELAPPjHS%2BlUE47FeJeMm2dqAMEoPvMwABpRAiBsC73cK4IktJl7ox2EA4uIMDZWQntfE2qhXikwCJAIkOYmAAGstjEHYpxPgwJSCIHurAvm2dsq5QLEJVkw9zKj05uPcugjK7CIlmTIkNJwKIG4nLaAVAqEAlYPAF0HdtS8WgDmWkXccHbmKkFaObttDcyeqMNhXApFiHGJgSYRCb4BFeObMRCtQnElpNASJngJjbDEfYukuB%2BB4I2jGCqF0p7CL9mTehjDlJ0y-kMCRHBpGyMDBeTGYAeq8IGkY8BDxIEkKTmIrB9cVwpN5uUJ82BCDoAPtqDRuctH5UHsJIpF90JXwgcQhJ1cxEUIcdQmZZh3JEWIJwwBx81rCFCP4HQxBfi5VkEAiIQA

Check out this GitHub issue for more details.

If this were a brand-new feature request, it would also be closed, as outlined here.

Please avoid opening similar issues in the future. For discussions on these topics, visit the F# Style Guide.