Closed Thorium closed 3 months ago
So this would be a rule whose purpose is optimization? (speed? memory?)
Yes, both. Similarly like testing IEnumerable isEmpty is optimization over "length > 0".
I'm closing this because this is already done in ionide-analyzers project. Over time that will already improve general F# code-bases on a level appropriate, there is no point of doing double amount of work implementing it here.
I'm stealing the great idea from @nojaf and adding it here as possible development as well. :-)
From FSharp.Core 6.0.1 onwards (F# 6):
A DU without any fields should be a struct:
Enums are fine, and this is a struct already:
Enums with simple fields like only boolean, int, Guid or struct could be also recommended to be structs, but that should be configurable, because that needs the name for the field, and changes may be a breaking change for existing API:
Partial active pattern that returns empty
()
, boolean, guid or int, should also be marked as[<return: Struct>]
and use ValueOption instead of Option:This comes from conversation in here: https://github.com/fsprojects/FSharp.Formatting/pull/906