Allow optional naming of union fields
It can be hard to keep track of field order, especially when there are several of the same time. For example: type MyUnion = Case1 of string * string * string. It's hard to remember which field is Id, Name, Description, and so on. If the fields could be notated -- type MyUnion = Case1 of Id:string * Name:string * Description:string -- then Intellisense could be provided when entering case constructors.
3 comments
-
Jack Pappas
commented
This feature was/is part of the Standard ML language. It seems the F# compiler originally supported this, because if you use VS2010 (F# 2.0) and try to use record syntax to define the type of a union case you'll get a compiler error message about it (saying that the feature is deprecated).
-
David Thayer
commented
You really want record definitions as TypeConstructer parameters
i.e Case1 of {Id:string; Name:string; Description:string } -
Daniel Robinson
commented
Not sure how to edit. "time" should be "type" in the first sentence.