Skip to content

Feature Request: TypedDynamic #826

@schlichtanders

Description

@schlichtanders

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions