-
Notifications
You must be signed in to change notification settings - Fork 161
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
Patch value with Diff #81
Comments
I would like to give this one a try. The 2 proposed signatures are: If we have a type A when can the function fail going from A to A? Not sure how to deal with String... For example: How do you apply diff1 to some other random String like "hello"? Any other thoughts or guidance would be appreciated as I am new to the Zio community. |
Thanks! The way I was thinking about it is that the patch is intended to be applied to the original value so applying to completely different value creates a "merge conflict" which would fail. In general, I think the main guideline for this one is that the patch itself should be pure data so we want to make it operation based and serializable. The string diff is already operation based but other diffs are not explicitly encoded that way currently. As an example, check out how we encode (and then apply) migrations in |
* Patch value with Diff #81 * Patch value with Diff #81 * Patch value with Diff #81 * Patch value with a Diff - fixing tests * Patch value with a Diff - fix formatting * Patch Value with a Diff - fixing formatting * Patch value with a Diff - fixing lint errors * Patch Value with a Diff - Fixing the Either case * Patch value for a Diff - fixed the either cases * Patch Value with a Diff - Added more tests * Patch Value with a Diff - fixing temporal fields * Patch Value with a Diff - move patch to Diff * Patch value with a Diff - removing patch from Differ
Closed by #132 |
* Patch value with Diff zio#81 * Patch value with Diff zio#81 * Patch value with Diff zio#81 * Patch value with a Diff - fixing tests * Patch value with a Diff - fix formatting * Patch Value with a Diff - fixing formatting * Patch value with a Diff - fixing lint errors * Patch Value with a Diff - Fixing the Either case * Patch value for a Diff - fixed the either cases * Patch Value with a Diff - Added more tests * Patch Value with a Diff - fixing temporal fields * Patch Value with a Diff - move patch to Diff * Patch value with a Diff - removing patch from Differ
This is a placeholder to gather thoughts but the initial idea is to:
Once #78 is implemented, we can add a method to the
Schema[A]
trait:which returns a
Left(error message)
if the diff cannot be applied to the schema structure (e.g. if I try to apply aDiff.Number
to aSchema.Record
and otherwise returns a function which will apply the specifieddiff
to value of typeA
(possibly failing).And associated syntax
Laws:
a: A
thena.patch(Diff.Identical) == Right(a)
a1: A
anda2: A
we should havea1.patch(a1.diff(a2)) == Right(a2)
a1: A
anda2: A
we should haveSome questions:
def patch(diff: Diff): Either[String, A => A]
instead?The text was updated successfully, but these errors were encountered: