fslang-suggestions
fslang-suggestions copied to clipboard
Allow some type declaration sub branches being annotated with meaningfull descriptions
I propose we allow to annotates some type declarations, besides DU's with the descriptions of what contextual info the underlying types are carrying Consider this DU type:
type DU =
| IdName of Id: string * Name: float
| Index of Index: int
it is possible to annotate the payload of the cases with inlined descriptions for DU's however it is not possible for Map
type for example:
type SomeMapData = System.Collections.Generic.SortedDictionary<versionId: string, Map<docName: string, docId: string>>
//or in function declaration
let foo (m: Map<name: string, id: string>) =
//....
The existing way of approaching this problem in F# is to declare type alias and create the documentation for it with description of what info is implied under certain string, int or float primitive. Even then its tricky to properly describe what subtree of type declaration is exactly being described. Another approach is to create separate single DU case for each of the primitive types involved, which is often not needed.
Pros and Cons
The advantages of making this adjustment to F# are more transparency in using standard types like tuples and maps and consistency with DU types
The disadvantages of making this adjustment to F# are hard to evolve for me, this annotations are already working for DU cases payload, so it probably can be generalized.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): ?
Affidavit (please submit!)
Please tick this by placing a cross in the box:
- [+] This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
- [+] I have searched both open and closed suggestions on this site and believe this is not a duplicate
- [+] This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.
Please tick all that apply:
- [ ] This is not a breaking change to the F# language design
- [ ] I or my company would be willing to help implement and/or test this
For Readers
If you would like to see this issue implemented, please click the :+1: emoji on this issue. These counts are used to generally order the suggestions by engagement.