-
Notifications
You must be signed in to change notification settings - Fork 5
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
Could there be a conflict with generic-lens-labels and similar libraries? #8
Comments
No, |
Ah, alright. Does that mean there is no conflict between these libraries? Or does the conflict still exist by virtue of that lib having orphans?
Yeah, I think that would be nice. Do you think it could be easy somehow? Any ideas how? Or would it likely be rather difficult to do? |
I didn’t try to use both libs together, but I predict there should be a conflict.
The lens instance could be defined for a newtype over |
As far as I am concerned If we declare it to not be an orphan, then the following would also not be an orphan:
At which point if I were to do:
Then I am going to get an overlapping instances error. Showing that our assertion that either of the above definitions are not orphans is wrong. It's also worth noting that it would be perfectly reasonable for |
Then you're using a different definition of an orphan instance, definitely not the one that e.g.
Overlapping instances are also possible in absence of orphans, so I don't think any conclusions follow from this.
I'll keep it in mind, so that if someone proposes this instance, I'll mention that it would conflict with existing libraries (e.g. |
Surprising that
Under my definition of orphans, they are only possible if both overlapping instances are defined in the same module (a clear and easy to fix error), or if at least one of the definitions is an orphan.
This is exactly why I don't like instances like If it does come down to a head-to-head between This is not to say that I am 100% in favor of the |
I don't think that's the whole reason people care about orphans. The real danger of orphans is that you can end up with different instances in scope in different parts of your code base and therefore get different behavior depending on where in the code the instance is chosen. |
Thanks for bringing that up. I should have mentioned that as well for sure. To be clear the above style of instance absolutely allows for different behavior depending on where in the code the instance is chosen. So you bring up another very good reason why we should absolutely not have the above instance, and why I was able to break
If you run the above code you will notice that You will also notice that ghc (IMO incorrectly) does not complain about any of it, even with |
And what is, exactly, your definition? What do you think of the example below?
Imagine this being split into several modules, with |
I actually made a reddit post here right after I made my comment addressing that exact situation. I would absolutely say that either Regardless if we do not include |
I wanted to bring attention to ghc-proposals/ghc-proposals#279 where a lot of the above is being discussed. On a personal note I still maintain that these instances are orphans, and that any If my desire for |
Hey, I'm just now getting to know this library. I have been waiting/looking for a nice implementation for named parameters for Haskell for a long time, so I am glad you've created this, and I'm glad to have found it.
However, seeing labels being used as functions gives me some pause. Could this library conflict with https://github.com/duog/generic-lens-labels? According to my admittedly fuzzy and likely spotty understanding, both of these libraries define orphan instances for
IsLabel (-> _)
, don't they? Meaning that only one of these can be used in a Haskell module (or perhaps even package?) at once, and never together, doesn't it? And if so far I am on the mark here, this mutual exclusion extends to any other libraries that define similar instances, doesn't it?So if I'm correct above, could one relatively nice way of overcoming this issue be defining an operator that takes the being-a-function-burden off of
IsLabel
's shoulder?E.g. above I've used
=:
, but could be a different one as well.(I also wonder if the type level operator
%
can be re-defined on the value level as well.)The text was updated successfully, but these errors were encountered: