-
Notifications
You must be signed in to change notification settings - Fork 76
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
Some sort of sourcecode.Caller[T] implicit #9
Comments
Fascinating. If that typed version of Caller can be done in a no-boilerplate kind of way, I have a suspicion that that's quite useful in a lot of different domains... |
As I imagine it, it would be a pretty trivial macro expanding implicitly[sourcecode.Caller[T]] into sourcecode.Caller[T](this) And letting this |
Something similar could be done for I would want to use a |
We have DSL's that would make great use of this, providing much richer compilation phase checks. |
@fizzy33 anything you could share? I'm interested in knowing what the use cases could be before implementing it and maybe having to change things again later |
Are the two obvious ones (that you have already mooted). I am intrigued and trying to work through a few more. One would be to augment our internal DI framework (that leverages guice and scala implicits) though I don't have a solid use case yet, though I am working on it ;-) |
trait Caller {
type Out
}
object Caller {
type Aux[Out0] = Caller { type Out = Out0 }
} So that we can have other type classes that depends on def info[A](message: String)(implicit caller : Caller.Aux[A], hasLogger: HasLogger[A]) = {
hasLogger.getLogger.info(message)
} |
See https://gigiigig.github.io/posts/2015/09/13/aux-pattern.html for the |
Use cases:
The text was updated successfully, but these errors were encountered: