Provide covariance/contravariance language support with syntaxes in F# in sync with covariance/contravariance in C#/VB
Covariance/contravariance has its beginning in CLR 2.0 and also with the introduction of generics in .NET 2.0 (also in F#, C# and VB)
Then in C# 4.0 and VB 10, we have covariance/contravariance supports in the language itself. Currently we don't have support for these covariance and contravariance in F#.
I know it is a runtime feature of CLR 2.0 and 4.0 and I don't want to play catch up with C# and VB.
But this covariance/contravariance support in C# and VB are powerful to use and also have proven to provide cleaner and clearer ways to understand the code and variances in the types, especially when using parameterized generic types.
This is not the same as this feedback:
but we can use that OCaml syntax as well for starter.
This feature should also be constrained to only use covariance/contravariance in interfaces and delegates just like in C# and VB, but F# may provide more supports for other types such as events.
An example of this is the way F# has provided the capability to create extensions to properties and methods, not just methods only in C# and VB.
There is a new community-driven user voice site for managing suggestions specifically related to the F# language design. https://fslang.uservoice.com/forums/245727-general
Please move this item there and link back to this entry, as the Visual Studio User Voice site is best used for suggestions related to the Visual F# Tools (rather than the language itself).
Don Syme, for the Visual F# Tools team
Sergey Shandar commented
Eriawan Kusumawardhono commented
Thanks Don! I'm moving this feedback to the FSLang.