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

Easier to disambiguate in #126

Merged
merged 5 commits into from
Nov 30, 2022
Merged

Easier to disambiguate in #126

merged 5 commits into from
Nov 30, 2022

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Nov 30, 2022

In this PR, instead of specializing in(v, ::T) where {T<:TypedEndpointsInterval}, we define

 in(v, I::TypedEndpointsInterval) = _in(v, I)

and specialize _in. This makes it easier for other packages to define in(v::CustomType, I::TypedEndpointsInterval) without having to resolve ambiguities with more specific types.

@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Base: 99.16% // Head: 99.17% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (e979412) compared to base (0661291).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head e979412 differs from pull request most recent head ddf5679. Consider uploading reports for the commit ddf5679 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #126   +/-   ##
=======================================
  Coverage   99.16%   99.17%           
=======================================
  Files           3        3           
  Lines         239      241    +2     
=======================================
+ Hits          237      239    +2     
  Misses          2        2           
Impacted Files Coverage Δ
src/IntervalSets.jl 98.33% <100.00%> (+0.02%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jishnub jishnub changed the title Easier to disambiguate in Easier to disambiguate in Nov 30, 2022
Copy link
Collaborator

@hyrodium hyrodium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Could you bumb the version to v0.7.4?
(x-ref: 0661291#commitcomment-91522252)

@jishnub
Copy link
Member Author

jishnub commented Nov 30, 2022

Should we instead define in(v, t::Domain) = _in(v, t), with the fallback

_in(v, t::Domain) = throw(ArgumentError("in(::$(typeof(v)), ::$(typeof(t))) is not defined"))

TypedEndpointsInterval seems like an internal type that packages might not be willing to disambiguate against.

EDIT: DomainSets.jl seems to be committing type-piracy with this currently, so it would be good to move those methods here

I've instead defined in(v, t::AbstractInterval) here.

Edit 2: Defining in(v, t::AbstractInterval) will actually create a more specific method than in(v, ::Domain) that is currently defined through piracy in DomainSets. This might lead to breakages. I've reverted to defining in(v, ::Domain) here. This means one would obtain "method overwritten" warnings when loading DomainSets, but nothing will break. We should eventually move the methods from DomainSets to this package, or perhaps to DomainSetsCore

Edit 3: This seems harder than I had thought because of the type-piracy. I've gone all the way back to the original idea presented in the first post.

@hyrodium
Copy link
Collaborator

I agree with all of your points. It seems better to have DomainSetsCore.jl package. (x-ref: #106 (comment))

@hyrodium hyrodium merged commit 245ab42 into JuliaMath:master Nov 30, 2022
@jishnub jishnub deleted the in branch November 30, 2022 14:44
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.

2 participants