Cheatsheet
Basic imports
import difflicious.*
import difflicious.implicits.*
Summoning Differ instances
val intListDiffer = Differ[List[Int]]
Deriving instances for case class and sealed traits (Scala 3 enums)
val differ = Differ.derived[Person]
Use Differ.derivedDeep when you want Difflicious to recursively derive missing field instances at that call site.
Existing instances in scope still take priority.
case class Address(city: String)
case class Employee(name: String, address: Address)
val differ = Differ.derivedDeep[Employee]
For classes with generic fields, Differ.derived needs you to also ask for the Differ instance of the field type
(not just the generic type).
case class Box[A](
content: List[A]
)
case class Factory[A](
boxes: List[Box[A]]
)
implicit def boxDiffer[A](implicit listDiffer: Differ[List[A]]): Differ[Box[A]] = Differ.derived[Box[A]]
implicit def factoryDiffer[A](implicit boxesDiffer: Differ[List[Box[A]]]): Differ[Factory[A]] = Differ.derived[Factory[A]]
val differ = Differ[Factory[Int]]
If you do not need to name those intermediate instances, derivedDeep can derive the missing instances recursively:
val differ = Differ.derivedDeep[Factory[Int]]
Configuring Differs
val differ = Differ[Map[String, List[Person]]]
differ.configure(_.each)(_.pairBy(_.name))
differ.configure(_.each)(_.pairByIndex)
differ.ignoreAt(_.each.each.name)
// Equivalent to differ.configure(_.each.each.name)(_.ignore)
// Replacing a differ at path
val anotherPersonListDiffer: Differ[List[Person]] = ???
differ.replace(_.each)(anotherPersonListDiffer)