Skip to content

Add hasUpperBound and hasLowerBound #2828

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

Merged
merged 1 commit into from
Sep 20, 2015

Conversation

snoyberg
Copy link
Collaborator

This is useful for performing PVP bounds checking, especially for
tooling that wants to automate such dependency bounds. A demonstration
of this being used in practice is the --pvp-bounds flag for stack:

commercialhaskell/stack@c774f99

hasUpperBound (EarlierVersion _) = True
hasUpperBound (WildcardVersion _) = True
hasUpperBound (UnionVersionRanges x y) = hasUpperBound x && hasUpperBound y
hasUpperBound (IntersectVersionRanges x y) = hasUpperBound x && hasUpperBound y
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that this is correct. Consider the intersection of >=1.0 with <=1.1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, good catch, thanks.

@23Skidoo
Copy link
Member

This may be easier to implement by converting VersionRange to VersionIntervals first. Also, it looks like other code in that file assumes that if the lower bound is not specified, then it is >=0 by default, so in a sense a lower bound always exists.

This is useful for performing PVP bounds checking, especially for
tooling that wants to automate such dependency bounds. A demonstration
of this being used in practice is the --pvp-bounds flag for stack:

commercialhaskell/stack@c774f99
@snoyberg snoyberg force-pushed the has-upper-lower-bound branch from 758f566 to 63d8fdb Compare September 20, 2015 07:31
@snoyberg
Copy link
Collaborator Author

Thanks for the pointer on VersionIntervals. It looks like it will work for upper bounds. However, with lower bounds, it's not going to work (at least for the way I'd want to implement this, which has to do with your second point). For PVP bounds purposes, the presence of an implicit lower bound (i.e., that 0 is the minimum version possible) is not my goal: it's to detect if the user explicitly stated a lower bound that should be respected (as opposed to omitting a lower bound, where tooling can add it in for the user).

@23Skidoo
Copy link
Member

LGTM now, so merging.

23Skidoo added a commit that referenced this pull request Sep 20, 2015
Add hasUpperBound and hasLowerBound
@23Skidoo 23Skidoo merged commit 5201501 into haskell:master Sep 20, 2015
@hvr
Copy link
Member

hvr commented Sep 21, 2015

c.f. #2774 which also contains similar predicates and or similar needs

@snoyberg
Copy link
Collaborator Author

Interesting, that looks like a very similar feature to what I was adding to stack

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