I propose we change F# lists reported type annotations to always use array instead of []. The existing default causes significant confusion, especially to people new to F#.
For example, the following output in FSI is incredibly confusing because it's apparently inconsistent to new users:
> let x = []
let y = [| |];;
val x : 'a list
val y : 'a []
While lists are declared using [ ], the type annotation shows list. Arrays, however, are declared using [| |], but the type annotation shows [], which "looks like an array" to new users. We very frequently get questions from people who are very confused when coming to F# because of this.
I propose to change type annotations which are reported (tooltips, FSI, intellisense) to display as this instead:
> let x = []
let y = [| |];;
val x : 'a list
val y : 'a array
Note that I am not suggesting changing or breaking compatibility. Using [] should still be allowed in manual type annotations. Today, you can easily use [] or array interchangeably. I am merely suggesting that all tooling should switch to suggesting array, as it'd be more in line with list, but also less confusing to new users.
Pros and Cons
The advantages of making this adjustment to F# are consistency for new users. Arrays would be obvious as arrays instead of being confused as lists.
The disadvantages of making this adjustment to F# are that it's a change from previous behavior.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S?
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
I propose we change F# lists reported type annotations to always use
arrayinstead of[]. The existing default causes significant confusion, especially to people new to F#.For example, the following output in FSI is incredibly confusing because it's apparently inconsistent to new users:
While lists are declared using
[ ], the type annotation showslist. Arrays, however, are declared using[| |], but the type annotation shows[], which "looks like an array" to new users. We very frequently get questions from people who are very confused when coming to F# because of this.I propose to change type annotations which are reported (tooltips, FSI, intellisense) to display as this instead:
Note that I am not suggesting changing or breaking compatibility. Using
[]should still be allowed in manual type annotations. Today, you can easily use[]orarrayinterchangeably. I am merely suggesting that all tooling should switch to suggestingarray, as it'd be more in line withlist, but also less confusing to new users.Pros and Cons
The advantages of making this adjustment to F# are consistency for new users. Arrays would be obvious as arrays instead of being confused as lists.
The disadvantages of making this adjustment to F# are that it's a change from previous behavior.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S?
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply: