Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Indentation Rules for Generic Signatures #504

Closed
4 of 6 tasks
cloudRoutine opened this issue Oct 31, 2016 · 1 comment
Closed
4 of 6 tasks

Improve Indentation Rules for Generic Signatures #504

cloudRoutine opened this issue Oct 31, 2016 · 1 comment

Comments

@cloudRoutine
Copy link

Currently the compiler allows for some interesting ways to write generic signatures

open System

    module Z =
        type Alpha< ^b, ^a 
    when ^     a    :  (member Name:string)
and    ^a:        (member Zip
   : ^b when
^b : struct   )
and             ^a
:                 (static member(+)
    :    'a * 'a 
-> 'a 
) 
         > () = 
            member inline __.X = ()
        with  
        static member inline Y = ()

Since this flies flagrantly in the face of the indentation rules, it'd be nice to fix this for the sake of consistency at the least.

This gives an indentation warning on the ( before static

type TypeWithALongName< ^a 
    when ^a:(static member(+):'a * 'a -> 'a )
    and  ^a:(static member(-):'a * 'a -> 'a )            
    and  ^a:(static member(*):'a * 'a -> 'a )            
    and  ^a:(static member(/):'a * 'a -> 'a )            
    > =
    static member inline X = ()

To fix the warning you have to indent this far

type TypeWithALongName< ^a 
                        when ^a:(static member(+):'a * 'a -> 'a )
                        and  ^a:(static member(-):'a * 'a -> 'a )            
                        and  ^a:(static member(*):'a * 'a -> 'a )            
                        and  ^a:(static member(/):'a * 'a -> 'a )            
    > =
    static member inline X = ()

The former seems like it would work based on the typical indentation approach of needing to be indented one space further than the start of the encompassing construct e.g.

let fn x y = fun z ->
 x * y * z

Pros and Cons

The advantages of making this adjustment to F# are ...

  • indentation consistency

The disadvantages of making this adjustment to F# are:

  • potential to break some horribly formatted code
  • more complex syntax parsing

Extra informtion

Estimated cost : M

Related suggestions:

Affadavit (must be submitted)

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I would be willing to help implement and/or test this
  • I or my company would be willing to help crowdfund F# Software Foundation members to work on this
@dsyme
Copy link
Collaborator

dsyme commented Sep 25, 2021

My understanding is this has been addressed as part of FS-1108, currently in preview https://github.com/fsharp/fslang-design/blob/main/preview/FS-1108-undentation-frenzy.md

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

No branches or pull requests

2 participants