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

hasLowerBound anyVersion #9163

Open
mpilgrem opened this issue Aug 7, 2023 · 3 comments
Open

hasLowerBound anyVersion #9163

mpilgrem opened this issue Aug 7, 2023 · 3 comments

Comments

@mpilgrem
Copy link
Collaborator

mpilgrem commented Aug 7, 2023

The Haddock documentation for Distribution.Types.VersionRange.hasLowerBound explains (as it has since before Cabal-3.4.0.0):

-- | Does the version range have an explicit lower bound?
--
-- Note: this function only considers the user-specified lower bounds, but not
-- the implicit >=0 lower bound.

Before Cabal-3.4.0.0, hasLowerBound anyVersion was False (anyVersion was AnyVersion). From Cabal-3.4.0.0, hasLowerBound anyVersion is True (the data constructor AnyVersion is no more, and anyVersion is now OrLaterVersion (mkVersion [0])).

Is this change in behaviour of hasLowerBound anyVersion what was intended when AnyVersion was dropped? Or should hasLowerBound v now begin not (isAnyVersion v) || ...?

Alternatively, could the current Haddock documentation be clarified, for example:

-- | Does the version range have an explicit lower bound?
--
-- Note: this function only considers the user-specified lower bounds, but not
-- an implicit >=0 lower bound. @hasLowerBound anyVersion@ yields @True@ as
-- the >=0 lower bound is express.

Edit: Depending on what was intended, I can raise a pull request.

@gbaz
Copy link
Collaborator

gbaz commented Aug 7, 2023

I feel like this is a change in the meaning of anyVersion from AnyVersion more than a change to hasLowerBound. Not sure in what cases it would make a difference, generally?

@mpilgrem
Copy link
Collaborator Author

mpilgrem commented Aug 7, 2023

What prompted me to raise this was that Stack was relying on hasLowerBound to decide whether or not to add a lower bound in stack sdist --pvp-bounds lower - it only added a lower bound if one was not already expressed. When dependency my-package in a Cabal file went from meaning implied ">= 0" (AnyVersion) to meaning my-package >= 0 (express ">=0"), it stopped working (it is now fixed).

I doubt if different Haddock documentation would have headed off the Stack bug, but it might help somebody. Not least, because the data constructors of VersionRange are semi-opaque (they are exposed only in Distribution.Types.VersionRange.Internal).

@gbaz
Copy link
Collaborator

gbaz commented Aug 7, 2023

Thanks for this report, I think its a wart semantically and probably should be cleaned up (in making anyVersion not have a lower bound) In general the changes to version stuff left us in a somewhat partial state, and this is another instance of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants