chwthewke / auto-diff

Structural diff functions for Scala types via generic derivation


Build Status Maven Central

Structural diff for scala types

This project provides the Difference ADT, which models structural diff of scala values. It is built (and depends) on cats and shapeless.

Differences are computed via the Diff[A] type class that wraps a function of type (A, A) => Option[Difference].

The goal of this library is to provide convenient and extensible generic derivation of Diff instances, as well as a decent textual representation of Difference values.

TODO: Add examples, with tut ideally

Current status

  • Diff instances can be derived for:

    • primitive types as well as String, UUID,
    • a selection of usual collection-like types, including Map, Option and Either
    • enumeratum Enums, via autodiff-enumeratum.
  • Generic derivation (for LabelledGeneric types) is provided by autodiff-generic, and is opt-in like e.g. in circe

    • either automatic with import
    • or semi-automatic with import fr.thomasdufour.autodiff.generic.semiauto._ and using deriveDiff
  • The Difference type has only a couple textual representation options and no convenience methods to speak of.

Future work

  • Further API exploration for the "front-end", including test framework integration.
  • Improve test coverage


xdotai/diff for inspiration.