Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: TypedDynamic #826

Open
schlichtanders opened this issue Apr 11, 2018 · 1 comment
Open

Feature Request: TypedDynamic #826

schlichtanders opened this issue Apr 11, 2018 · 1 comment
Labels

Comments

@schlichtanders
Copy link

schlichtanders commented Apr 11, 2018

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.

@schlichtanders
Copy link
Author

There is already a scala-compiler plugin, implementing such a feature, and listing some usecases in its wiki-page https://github.com/scala-incubator/autoproxy-plugin

However it wasn't maintained for amazing 7 years... hopefully maintaining such a feature within shapeless can be easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants