You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
[<Struct>]typeMyType=| A
| B
Enums are fine, and this is a struct already:
typeMyType=| A =1| B =2
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:
[<Struct>]typeMyType=| A ofa:int| B ofb:struct(bool*bool)
Partial active pattern that returns empty (), boolean, guid or int, should also be marked as [<return: Struct>] and use ValueOption instead of Option:
[<return: Struct>]let(|MyThing|_|)x =if x then ValueSome()else ValueNone
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:
fsprojects/FSharp.Formatting#906
The text was updated successfully, but these errors were encountered: