stacycurl / delta Goto Github PK
View Code? Open in Web Editor NEWType safe delta
License: Apache License 2.0
Type safe delta
License: Apache License 2.0
By moving the current instances into a hlist.unlabelled object and creating a hlist.labelled object.
See https://github.com/milessabin/shapeless/blob/master/examples/src/main/scala/shapeless/examples/sexp.scala for an example a hlist instance that uses labels.
I'm planning on making Delta[scala.xml.Node] == scala.xml.Node & Delta[Json] == Json, so this could be applied more generally.
Example Set(1, 2).delta(Set(2, 3)) currently is SetPatch(added = Set(3), removed = Set(1)), it could be Set((Added, 3), (Removed, 1)) (SetPatch could extend Set to provide both).
Similarly Map(1 -> 1, 2 -> 2).delta(Map(2 -> 22, 3 -> 3)) == MapPatch(removed = Map(1 -> 1), added = Map(3 -> 3), changed = Map(2 -> 2.delta(22))), it could (almost) be Map(Removed -> Map(1 -> 2), Added -> Map(3 -> 3), Changed -> Map(2 -> 2.delta(22))).
A little bit of documentation should be good. At least, a README with few examples.
Example
{ a: 1, b: 2, c: {d: 3, e: 4} } should beIdenticalTo({ a: 1, c: {d: 3, e: 5} }) // fails due to differences
{ a: 1, b: 2, c: {d: 3, e: 4} } should beIdenticalTo({ a: 1, c: {d: 3, e: 5} }).ignoring("/b", "/c/e") // passes
{ a: 1, b: 2, c: {d: 3, e: 4} } should beDifferentTo({ a: 1, b: 20, c: {d: 3, e: 40} }) // passes
{ a: 1, b: 2, c: {d: 3, e: 4} } should beDifferentTo({ a: 1, b: 20, c: {d: 3, e: 40} }).ignoring("/b", "/c/e") // fails
{a: 1, b: 2, c: { d: 3 } } should beIdenticalTo {a: 1, c: {d: 3}} ignoringNot("/a, /c/d")
where the paths are derived from the expectation.
This is a very cool project!
Any chance for a Scala 2.11 build?
Best wishes,
William
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.