Replies: 3 comments
-
I suggest a different solution to the The key concept is an interface specifies the shape of a type, by giving an example of the type. Here it would be: interface INumeric TSelf
{
abstract static TSelf Zero { get; }
abstract static TSelf operator +(TSelf a, TSelf b);
} One of the advantages of this approach, is it makes HKTs really easy to express: public interface IFunctor TSelf<T>
{
TSelf<S> Map<S>(Func<T, S> func);
} As well as things like e.g. requiring constructors, nested classes, operators, etc. Without requiring any new syntax. |
Beta Was this translation helpful? Give feedback.
-
For the self problem in most simplistic solution: maybe introduce special keyword interface INumeric<self>
{
abstract static self Add(...);
} This would under the hood turn into interface INumeric<TSelf> where TSelf : INumeric<TSelf>
{
abstract static TSelf Add(...);
} Or even more simplistic: interface INumeric<TSelf> where TSelf : self
{
abstract static TSelf Add(...);
} This alternative way is even self explanatory i think and wouldnt require slighty different codegen when appearing on generics and when on type members |
Beta Was this translation helpful? Give feedback.
-
That seems to overlap with #902 a bit IMO, though I would love it if that could solve this problem. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/dotnet/csharplang/blob/master/meetings/2020/LDM-2020-06-29.md
Agenda
I would like to thank @agocke for his continued work on the LDM notes, and hope that I can fill his shoes well as he moves to a new team!
Beta Was this translation helpful? Give feedback.
All reactions