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

Update discussion about Equatable and Hashable in README after #56 #60

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

calda
Copy link
Member

@calda calda commented Sep 28, 2024

This section of the README is no longer necessary after #56.

@calda calda merged commit 1e136af into master Sep 28, 2024
3 checks passed
@calda calda deleted the cal--update-readme branch September 28, 2024 23:55
@GeorgeLyon
Copy link
Collaborator

Sorry, I meant we should probably consider the rationale laid out in that comment with regard to adding those conformances directly in ResilientDecoding. But also, I'm not actively using this anymore so do what you think is right.

The risk here is if you have something like:

struct Foo: Equatable {
  @Resilient var bar: Int?
}
let firstFoo = try decoder.decode(Foo.self, from: """
  {"bar":"3"}
  """)
let secondFoo = try decoder.decode(Foo.self, from: """
  {"bar":"not 3"}
  """)
firstFoo == secondFoo // true, but "3" != "not 3"

@dfed
Copy link
Collaborator

dfed commented Sep 29, 2024

The wrapped value in this example wouldn't be equal, though, would it? Since 3 != nil?

Certainly you could end up in cases where different errors are treated as equivalent, but at that point the underlying/wrapped value (nil) is indeed equivalent.

@GeorgeLyon
Copy link
Collaborator

The 3 wouldn’t decode because it is a string, sorry to make it confusing by picking a number.

My original position was that this was a design decision best left up to the user. If you look at a resilient type as equivalent to its non-resilient definition, then equating resilients makes sense. On the other hand, if you think about a resilient type as representing the original encoded entity, perhaps a little bit massaged to make decoding works, it no longer makes sense to have the “encountered an error” case be equal to the “didn’t encounter an error” case.

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

Successfully merging this pull request may close these issues.

3 participants