Diffx supports auto and semi-auto derivation.

For semi-auto derivation you don’t need any additional import, just define your instances using:

import com.softwaremill.diffx._
case class Product(name: String)
case class Basket(products: List[Product])

implicit val productDiff = Diff.derived[Product]
implicit val basketDiff = Diff.derived[Basket]

To use auto derivation add following import


or extend trait

Auto derivation might have a huge impact on compilation times, because of that it is recommended to use semi-auto derivation.

Given that you have auto-derivation enabled you can summon diff instances as you would summon any other implicit type-class by using implictly[Diff[T]]. You can also write a shorter version Diff[T] which will be equivalent. However, if you would like to modify somehow (see ignoring and modifying) given instance and put it back into to the implicit scope:

implict val diffForMyClass: Diff[MyClass] = Diff[MyClass].doSomething

you will get a forward reference error.

To overcome that issue there is a Derived wrapper which allows you to summon a wrapped instance.

implict val diffForMyClass: Diff[MyClass] = implicitly[Derived[Diff[MyClass]]].value.doSomething

There is a summon method to make it more convenient. Below code is equivalent to the one above.

implict val diffForMyClass: Diff[MyClass] = Diff.summon[MyClass].doSomething