-
Notifications
You must be signed in to change notification settings - Fork 527
Description
Dear shapeless-team,
stumbling upon Proxies/Dynamic I found this scala-users question https://users.scala-lang.org/t/how-about-a-typed-dynamic/989/8
It speaks about a trait TypedDynamic[T] extends T which I would really like to have available just now ;-). More concretely, I think that the needed interface is a abstract class TypedDynamic[T](t: T) extends T
From my intuitive understanding it seems that shapeless is just the right spot to implement such a feature.
Let me demonstrate the functionality I am particularly after:
// given some Interfaces like T and functionalities thereupon like f ...
val t: T = ...
def f(t: T) = ...
// ... I would like to be able to CONVENIENTLY overwrite specific methods
// of the interface T while still being able to use function f
// ... "abstract class TypedDynamic[T](t:T) extends T" is supposed to give just that
// and should be usable like
f(new TypedDynamic(t){
def mySpecificMethofWhichIWouldLikeToOverwrite(...) = ...
})The crucial point is that ONLY the overwritten method needs to be provided and all (other) methods of T
have suitable default implementations referring to the provided t:T itself.
Is this possible?
Is this easily possible?
thanks a lot for reading!
EDIT: concerning naming,
I find it more intuitive to speak of this as Proxy[T] instead of TypedDynamic, however because the latter was used the scala-user question, I sticked to it for the example.