love-haskell / coercible-utils

Utility functions for Coercible types
https://hackage.haskell.org/package/coercible-utils
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

How reasonable would it be to have Identity a be Similar to a? #25

Closed kozross closed 5 years ago

kozross commented 5 years ago

From further investigations regarding issues raised in #24, I found that a possible solution to all my concerns would be the ability to have an instance Similar (Identity a) a. That would mean that I could recover the older flexibility of over2 by writing unpack . over2. However, as I don't know the details of the implementation, I'm not sure if this is feasible or if it would break some other assumptions.

treeowl commented 5 years ago

No, I don't think that can work very well. Using overlapping instances will definitely cause trouble for typed holes (even worse error messages! Yay!). Using incoherent instances will work okay in many cases, but I'm not sure how reliable it is and it limits some other potential future changes. Additionally, ad hoc instances here seem likely to confuse a lot of people. I'm not a fan. I'd much rather add new combinators to get the power you need, and resurrect the old API.

kozross commented 5 years ago

Yeah, in retrospect, this doesn't even address the problem I thought it did. Thank you for clarifying though - it'll help me come up with a good motivating example explaining what I need more clearly.