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

formatting: wider lists #1444

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ insert_final_newline = true
trim_trailing_whitespace = false

[*.fs]
fsharp_max_array_or_list_width=80
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nojaf It does feel to me that these defaults can be wider for F# code, likewise the other settings here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened fsprojects/fantomas#2288 to discuss this.

fsharp_max_array_or_list_number_of_items=5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fsharp_max_array_or_list_number_of_items does not do anything on its own.
You need to add fsharp_array_or_list_multiline_formatter=number_of_items for this to do anything. And please don't, I regress this setting exists in the first place.

fsharp_max_if_then_else_short_width=60
fsharp_max_dot_get_expression_width=80
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ You can see the version history [here](RELEASE_NOTES.md).
- Install the .NET SDK specified in the `global.json` file
- `build.sh -t Build` or `build.cmd -t Build`

## Formatting

dotnet fake build -t Format
dotnet fake build -t CheckFormat

## Documentation

This library comes with comprehensive documentation. The documentation is
Expand Down
23 changes: 4 additions & 19 deletions src/CommonRuntime/StructuralInference.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,10 @@ let typeTag =

let private conversionTable =
[ typeof<Bit>, [ typeof<Bit0>; typeof<Bit1> ]
typeof<bool>,
[ typeof<Bit0>
typeof<Bit1>
typeof<Bit> ]
typeof<int>,
[ typeof<Bit0>
typeof<Bit1>
typeof<Bit> ]
typeof<int64>,
[ typeof<Bit0>
typeof<Bit1>
typeof<Bit>
typeof<int> ]
typeof<decimal>,
[ typeof<Bit0>
typeof<Bit1>
typeof<Bit>
typeof<int>
typeof<int64> ]
typeof<bool>, [ typeof<Bit0>; typeof<Bit1>; typeof<Bit> ]
typeof<int>, [ typeof<Bit0>; typeof<Bit1>; typeof<Bit> ]
typeof<int64>, [ typeof<Bit0>; typeof<Bit1>; typeof<Bit>; typeof<int> ]
typeof<decimal>, [ typeof<Bit0>; typeof<Bit1>; typeof<Bit>; typeof<int>; typeof<int64> ]
typeof<float>,
[ typeof<Bit0>
typeof<Bit1>
Expand Down
10 changes: 1 addition & 9 deletions src/CommonRuntime/TextConversions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@ module private Helpers =
type TextConversions private () =

/// `NaN` `NA` `N/A` `#N/A` `:` `-` `TBA` `TBD`
static member val DefaultMissingValues =
[| "NaN"
"NA"
"N/A"
"#N/A"
":"
"-"
"TBA"
"TBD" |]
static member val DefaultMissingValues = [| "NaN"; "NA"; "N/A"; "#N/A"; ":"; "-"; "TBA"; "TBD" |]

/// `%` `‰` `‱`
static member val DefaultNonCurrencyAdorners = [| '%'; '‰'; '‱' |] |> Set.ofArray
Expand Down
18 changes: 2 additions & 16 deletions src/Html/HtmlRuntime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,7 @@ module HtmlRuntime =
let data =
let getContents contents =
contents
|> List.map (
innerTextExcluding
[ "table"
"ul"
"ol"
"dl"
"sup"
"sub" ]
)
|> List.map (innerTextExcluding [ "table"; "ul"; "ol"; "dl"; "sup"; "sub" ])
|> String.Concat
|> normalizeWs

Expand Down Expand Up @@ -362,13 +354,7 @@ module HtmlRuntime =
let rows =
list.Descendants("li", true)
|> Seq.map (
innerTextExcluding
[ "table"
"ul"
"ol"
"dl"
"sup"
"sub" ]
innerTextExcluding [ "table"; "ul"; "ol"; "dl"; "sup"; "sub" ]
>> normalizeWs
)
|> Seq.toArray
Expand Down
7 changes: 2 additions & 5 deletions src/Json/JsonGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ module JsonTypeBuilder =

let tupleType =
Microsoft.FSharp.Reflection.FSharpType.MakeTupleType(
[| keyResult.ConvertedType
valueResult.ConvertedType |]
[| keyResult.ConvertedType; valueResult.ConvertedType |]
)

let itemsSeqType = typedefof<_ seq>.MakeGenericType ([| tupleType |])
Expand Down Expand Up @@ -566,9 +565,7 @@ module JsonTypeBuilder =
typeof<string * obj>,
args
|> List.mapi (fun i a ->
Expr.NewTuple
[ Expr.Value names.[i]
Expr.Coerce(a, typeof<obj>) ])
Expr.NewTuple [ Expr.Value names.[i]; Expr.Coerce(a, typeof<obj>) ])
)

let cultureStr = ctx.CultureStr
Expand Down
3 changes: 1 addition & 2 deletions src/WorldBank/WorldBankProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ type public WorldBankProvider(cfg: TypeProviderConfig) as this =

// ASSUMPTION: Follow www.worldbank.org and only show these sources by default. The others are very sparsely populated.
let defaultSources =
[ "World Development Indicators"
"Global Financial Development" ]
[ "World Development Indicators"; "Global Financial Development" ]

let worldBankType =
createTypesForSources (defaultSources, "WorldBankData", false, false)
Expand Down
8 changes: 1 addition & 7 deletions src/WorldBank/WorldBankRuntime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,7 @@ module Implementation =
member internal __.GetDataAsync(countryOrRegionCode, indicatorCode) =
async {
let! data =
getData
[ "countries"
countryOrRegionCode
"indicators"
indicatorCode ]
[ "date", "" ]
"date"
getData [ "countries"; countryOrRegionCode; "indicators"; indicatorCode ] [ "date", "" ] "date"

return
seq {
Expand Down
12 changes: 3 additions & 9 deletions src/Xml/XmlGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,7 @@ module internal XmlTypeBuilder =
|> Seq.take attrParameters.Length
|> Seq.toList
|> List.mapi (fun i a ->
Expr.NewTuple
[ Expr.Value attrNames.[i]
Expr.Coerce(a, typeof<obj>) ])
Expr.NewTuple [ Expr.Value attrNames.[i]; Expr.Coerce(a, typeof<obj>) ])
)

let elements =
Expand All @@ -587,16 +585,12 @@ module internal XmlTypeBuilder =
)
|> Seq.toList
|> List.mapi (fun i a ->
Expr.NewTuple
[ Expr.Value childElemNames.[i]
Expr.Coerce(a, typeof<obj>) ])
Expr.NewTuple [ Expr.Value childElemNames.[i]; Expr.Coerce(a, typeof<obj>) ])

let elements =
match primitiveParam with
| Some _ ->
Expr.NewTuple
[ Expr.Value ""
Expr.Coerce(args.[attrParameters.Length], typeof<obj>) ]
Expr.NewTuple [ Expr.Value ""; Expr.Coerce(args.[attrParameters.Length], typeof<obj>) ]
:: elements
| None -> elements

Expand Down