navigation

FavourSingleton (FL0089)

Introduced in 0.26.10

Cause

Rule to detect usage of lists or arrays with only one item.

Rationale

List.singleton foo/Array.singleton foo is more readable and explicit than [foo]/[|foo|]. Especially if we take in account that F# newbies may not yet be familiar with the difference between inline array vs list instantiation; and square brackets with only one element could potentially be confused with an indexing accessor.

How To Fix

Replace all occurrences of single member lists/arrays with a call to List.singleton/Array.singleton.

Rule Settings

{
    "favourSingleton": {
        "enabled": false
    }
}