fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

explicit generic type arguments and constraints not according to the style guide

Open cmeeren opened this issue 3 years ago • 1 comments

Issue created from fantomas-online

Code and expected formatting

type LimitedValue<'validator, 'config, 'inner
    when 'validator :> Validator<'config, 'inner>
    and 'validator : (new: unit -> 'validator)>
    =
    | LimitedValue of 'inner

Result

type LimitedValue<'validator, 'config, 'inner when 'validator :> Validator<'config, 'inner> and 'validator: (new :
    unit -> 'validator)> = LimitedValue of 'inner

Problem description

Not formatted according to official guidelines.

Extra information

  • [ ] The formatted result breaks by code.
  • [ ] The formatted result gives compiler warnings.
  • [ ] I or my company would be willing to help fix this.

Options

Fantomas 4.6 branch at 10/20/2021 08:35:15 - 0f59676a0bc9456879b809ac7de3aca6c71669bb

Default Fantomas configuration

cmeeren avatar Oct 23 '21 21:10 cmeeren

Are you interested in submitting a fix for this? If so, please target the 4.7 branch.

nojaf avatar Oct 24 '21 17:10 nojaf

The result is different now, I'd say perhaps even fixed:

Line length 120:

type LimitedValue<'validator, 'config, 'inner
    when 'validator :> Validator<'config, 'inner> and 'validator: (new: unit -> 'validator)> = LimitedValue of 'inner

Line length 100:

type LimitedValue<'validator, 'config, 'inner
    when 'validator :> Validator<'config, 'inner> and 'validator: (new: unit -> 'validator)> =
    | LimitedValue of 'inner

Line length 80:

type LimitedValue<'validator, 'config, 'inner
    when 'validator :> Validator<'config, 'inner>
    and 'validator: (new: unit -> 'validator)> = LimitedValue of 'inner

I think it would make sense to have LimitedValue of 'inner be on a separate line when the type parameters and constraints break over multiple lines, but that's a style guide issue. I'm not bothered enough by the current result to submit an issue there, but I just wanted to mention it for the record.

cmeeren avatar Jan 07 '23 16:01 cmeeren