Is there a way to implicitly convert an implicit parameter in Scala?

You almost made it. You only need to declare a implicit: implicit def aToB(implicit a: A) = new B In this case compiler tries to find some implicit B for the first implicit argument of f and it finds aToB Than compiler ties to satisfy aToB s requirement ( implicit a: A ) and finds your implicit val a.

You almost made it. You only need to declare a implicit: implicit def aToB(implicit a: A) = new B In this case compiler tries to find some implicit B for the first implicit argument of f and it finds aToB. Than compiler ties to satisfy aToB's requirement (implicit a: A) and finds your implicit val a.

Thanks, it works for my simple example, but leads to 'diverging implicit expansion' in Lift's case. Let's see if anything can be done there... – Oleg Galako Mar 5 at 16:15.

This is probably not the best and most concise solution to this problem. But it was interesting for me whether it's technically possible to achieve what you want. I tried to reproduce all involved classes as close as possible without Lift... and here is one of the possible solutions using view bounds: class DbAccess class UserStoreT(implicit db: T, ev: T => DbAccess) class VendorT (val vend: T) class FactoryMakerT (vend: T) extends VendorT(vend) implicit def vendorToValT(vendor: VendorT) = vendor.

Vend implicit val db: VendorDbAccess = new FactoryMakerDbAccess(new DbAccess) {} implicit val userStore = new FactoryMakerUserStoreVendorDbAccess(new UserStore) {} In this case UserStore knows fact, that T is not DbAccess, but it also knows that T can be viewed and used as T. Edit About your second example (in comment). This simple workaround comes to my mind: class A class B trait ghPrio def f(implicit b: B) {} implicit val a = new A with ghPrio implicit def aToB(implicit a: A with implicit def bToA(implicit b: B) = new A; f ... not sure whether it will work in your Lift case.

The problem is this single line implicit def vendorToValT(vendor: VendorT) = vendor. Vend leads to 'diverging implicit expansion' on any implicit parameter because there is the opposite conversion (from T to VendorT) in scope and seems like I can't get rid of it. – Oleg Galako Mar 5 at 17:18 In other words the situation is like this: class A; class B; def f(implicit b: B) {}; implicit val a = new A; implicit def aToB(implicit a: A) = new B; implicit def bToA(implicit b: B) = new A; f – Oleg Galako Mar 5 at 17:23 Thanks again for trying to help, but there is one more thing going on, which can be illustrated by this: class A; case class VendorT(v: T); def f(implicit a: A) {}; implicit val vendor = Vendor(new A); implicit def vendorToValT(implicit v: VendorT) = v.

V; f – Oleg Galako Mar 5 at 19:31.

Here is a simple setup with two traits, a class with a covariant type parameter bounded by the previous traits, and a second class with a type parameter bounded by the other class. For both classes, a particular method is available (via implicit evidence) only if one of the two traits underlies the type parameter. However, since Bar is covariant in F, I shouldn't need the F parameter in Grill.

I should just require that B is a subtype of BarReadableFoo. Why is the implicit evidence not being taken into account?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions