-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Hi,
I don't know i this has been asked somewhere already, so please forgive me if it does. My search didn't find any results. This might been similar: https://github.com/dotnet/coreclr/issues/990
I have been using C# and VB.NET for a few years and for me what makes those languages incredible is tooling but also the fact that you can produce both quite low-level code and very abstract code.
The Functional Programming paradigm has enabled non-performance-critical oriented developers to avoid many pitfalls and to reuse code. Languages such as Scala, F# or C# have proven that it can be combined successfully with an OOP approach.
Unfortunately C# doesn't support Higher Kind Polymorphism and this apparently comes from the CLR not supporting it. (See dotnet/roslyn#2212).
It would enable programmers /languages to write functions such as:
public static T<A> To<T, A>(this IEnumerable<A> xs)
where T : <>, new(), ICollection<>
{
var ta = new T<A>();
foreach(var x in xs) {
ta.Add(x);
}
return ta;
}
In the current form either you specialize the functions by hand (IE write a lot of overloads) or end up returning and interface (such as IEnumerable<T>) where you lose Type information.
I know changing the IL is a pain but it will need to happen eventually, I just wanted to make sure that when it does, Higher Kinded Polymorphism is included.