Skip to content
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

Implemented automatic diff #78

Closed
thinkharderdev opened this issue Jun 12, 2021 · 0 comments
Closed

Implemented automatic diff #78

thinkharderdev opened this issue Jun 12, 2021 · 0 comments

Comments

@thinkharderdev
Copy link
Contributor

We should be able to use a Schema[A] to automatically diff values of type A.

To do this we should add a method like so

trait Schema[A] { self =>
  def diff(thisValue: A, thatValue: A): Diff =  DiffAlgorithm.fromSchema(self)(thisValue,thatValue)
}

Where we have DiffAlgorithm and Diff that look something like

trait DiffAlgorithm[A] { self =>
  def apply(thisValue: A, thatValue: A): Diff
}

object DiffAlgorithm {
  def fromSchema[A](schema: Schema[A]): DiffAlgorithm[A] = ???
}

sealed trait Diff
object Diff {
  final case object Identical extends Diff
  final case class Number[A : Numeric](distance: A) extends Diff
  final case class Tuple(leftDifference: Diff, rightDifference: Diff) extends Diff
  // etc
}
thinkharderdev added a commit to thinkharderdev/zio-schema that referenced this issue Jun 14, 2021
thinkharderdev added a commit to thinkharderdev/zio-schema that referenced this issue Jun 14, 2021
thinkharderdev added a commit to thinkharderdev/zio-schema that referenced this issue Jun 27, 2021
jdegoes pushed a commit that referenced this issue Jul 12, 2021
* Remove setup gpg

* Update setup-java

* Test

* test2

* test 3

* Fixes #78: Implement diffing between instances described by a schema

* Specs and additional implementations

* Rename DiffAlgorithm to Differ

* Add diffs for product and sum types

* Copy Myers diff implementation from zio-test

* Implement binary diff and unit tests

* Fix various temporal diffs and add unit tests

* formatting

* Test coverage and tweaks

* Fixes #12: Implement Schema.serializable

* Formatting

* Remove commented code

* Refactoring for clarity and type safety

* Refactor for clarity

* Test coverage and (ignored) test cases for recursive data types

* linting

* Better encoding of serializable schema with an Abstract Syntax Tree.
This allows us to check for cyclic references while building the tree
and replace recursive references with pointers.

Also fixed a bug with JSON encoding/decoding of recursive data types and
fixed derivation of recursive ADTs by inserting laziness into the
implicit conversions.

* Fix bugs in protobuf decoding

* 2.12 does not suport by-name implicit parameters

* Re-enable dynamic value test for recursive data types

* AST materialization and unit tests

* Remove ref method from Schema

* Preserve ref map on recursive materializations

* Add multi-dimensionality to schema to account for sequences of sequences

* Do AST comparison on Lazy schemas by limiting stack depth to avoid infinite recurse

* Rename Ast to SchemaAst to avoid conflicts

* Appease the 2.12 compiler

Co-authored-by: thinkharder <thinkharderdev@users.noreply.github.com>
landlockedsurfer pushed a commit to landlockedsurfer/zio-schema that referenced this issue May 28, 2022
…hema (zio#79)

* Remove setup gpg

* Update setup-java

* Test

* test2

* test 3

* Fixes zio#78: Implement diffing between instances described by a schema

* Specs and additional implementations

* Rename DiffAlgorithm to Differ

* Add diffs for product and sum types

* Copy Myers diff implementation from zio-test

* Implement binary diff and unit tests

* Fix various temporal diffs and add unit tests

* formatting

* Test coverage and tweaks

* Alphabetical sorting and comments on diff method

Co-authored-by: thinkharder <thinkharderdev@users.noreply.github.com>
landlockedsurfer pushed a commit to landlockedsurfer/zio-schema that referenced this issue May 28, 2022
* Remove setup gpg

* Update setup-java

* Test

* test2

* test 3

* Fixes zio#78: Implement diffing between instances described by a schema

* Specs and additional implementations

* Rename DiffAlgorithm to Differ

* Add diffs for product and sum types

* Copy Myers diff implementation from zio-test

* Implement binary diff and unit tests

* Fix various temporal diffs and add unit tests

* formatting

* Test coverage and tweaks

* Fixes zio#12: Implement Schema.serializable

* Formatting

* Remove commented code

* Refactoring for clarity and type safety

* Refactor for clarity

* Test coverage and (ignored) test cases for recursive data types

* linting

* Better encoding of serializable schema with an Abstract Syntax Tree.
This allows us to check for cyclic references while building the tree
and replace recursive references with pointers.

Also fixed a bug with JSON encoding/decoding of recursive data types and
fixed derivation of recursive ADTs by inserting laziness into the
implicit conversions.

* Fix bugs in protobuf decoding

* 2.12 does not suport by-name implicit parameters

* Re-enable dynamic value test for recursive data types

* AST materialization and unit tests

* Remove ref method from Schema

* Preserve ref map on recursive materializations

* Add multi-dimensionality to schema to account for sequences of sequences

* Do AST comparison on Lazy schemas by limiting stack depth to avoid infinite recurse

* Rename Ast to SchemaAst to avoid conflicts

* Appease the 2.12 compiler

Co-authored-by: thinkharder <thinkharderdev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant