I’m looking at your original one. How can valueBySmashing… take a Foo and return a Bar?
Conversation
It couldn’t without the <T, U> formulation from my comment. Didn’t see that he needed that. Updated.
1
This doesn't work — but I'm not sure why it doesn't work.
2
in this, U is determined by the caller and can be anything. But impl always returns Bar.
2
Yep. Okay. No way to fix this without making Value hetero-equatable, as said. :(
3
In other words, falling back to guard let x = x as Value else { abort }?
1
No, adding isEqual(Value) to Value instead of “: Equatable".
1
That tweet would be the imply of a Value’s isEqual—runtime type constraint. 😔
2
? You could implement a total isEqual(Value) depending on your semantics.
1
I had assumed the real motivating case wouldn’t permit a total isEqual.
1
Replying to
Can even use == with HeteroEquatable (updated the gist)
1




