And I discuss some ways that could be integrated with the extension everything proposal here: https://github.com/dotnet/csharplang/issues/164
The problem with both is that there's a new notion of "shape" or "concept" that's different from interfaces. It would be nice to just use interfaces for this (which is what I hint at in the video), but that comes with its own downsides and limitations.
Really? I'm not an expert but everything I've read until this implies the opposite. Besides, C# already has implicit conversions, and they're different from type classes in that they convert, not extend. Once an int is implicitly converted to a double, it's always a double from within the function that converted it, not just "representing" a double. So strictly less powerful than polymorphism. My understanding that type classes were the way out of that, and traits were Scala's equivalent. Is that not correct?
trait Show[T] { def show(v : T): String }
implicit object ShowInt extends Show[Int] {
def show(i: Int) = i.toString
}
def showLine[T](v : T)(implicit show: Show[T]): Unit = {
println(show.show(v))
}Assume you're thinking about C#'s extension methods, which in Scala are achieved via implicit classes.