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

Implement Caret-style version range operator #3705

Merged
merged 1 commit into from Sep 1, 2016

Conversation

Projects
None yet
4 participants
@hvr
Copy link
Member

hvr commented Aug 20, 2016

This implements a new syntactic sugar: The version range operator
^>= which is equivalent to >= intersected with an
automatically inferred major upper bound.

This new syntax is only allowed for cabal-version: >=2.0, and
allows to describe the most common use of version
bounds more conveniently:

build-depends: foo ^>= 1.2.3.4,
               bar ^>= 1

The declaration above is exactly equivalent to

build-depends: foo >= 1.2.3.4 && < 1.3,
               bar >= 1 && < 1.1

The ^-symbol was chosen because it can serve as a mnemonic when the
> sign is rotated and interpreted as "less than ceiling"

Moreover, ^ appears to become a quasi-standard to denote morally
equivalent operator that way in other language ecosystems which similiar
to Haskell have adopted semantic versioning:

Ruby, on the other hand, uses a Tilde operator (~>) for that
purpose (but with a less robust semantic):

And Python is currently planing to use an ~= operator:

@phadej

This comment has been minimized.

Copy link
Collaborator

phadej commented Aug 20, 2016

LGTM. But I'll like to see tests. (which would break in parsec branch)

@23Skidoo

This comment has been minimized.

Copy link
Member

23Skidoo commented Aug 22, 2016

/cc @dcoutts

@23Skidoo

This comment has been minimized.

Copy link
Member

23Skidoo commented Aug 22, 2016

Would be nice to add a changelog note.

@hvr hvr force-pushed the hvr:pr/caret-version-range-op branch 2 times, most recently from ae63fb8 to 5036c46 Sep 1, 2016

Implement Caret-style version range operator
This implements a new syntactic sugar: The version range operator
`^>=` which is equivalent to `>=` intersected with an
automatically inferred major upper bound.

This new syntax is only allowed for `cabal-version: >=2.0`, and
allows to describe the most common use of version
bounds more conveniently:

    build-depends: foo ^>= 1.2.3.4,
                   bar ^>= 1

The declaration above is exactly equivalent to

    build-depends: foo >= 1.2.3.4 && < 1.3,
                   bar >= 1 && < 1.1

The `^`-symbol was chosen because it can serve as a mnemonic when the
`>` sign is rotated and interpreted as "less than ceiling"

Moreover, `^` appears to become a quasi-standard to denote morally
equivalent operator that way in other language ecosystems which similiar
to Haskell have adopted semantic versioning:

 - Node: https://nodesource.com/blog/semver-tilde-and-caret/
 - Bower: https://bower.io/docs/api/#install
 - PHP: https://getcomposer.org/doc/articles/versions.md#caret

Ruby, on the other hand, uses a Tilde operator (`~>`) for that
purpose (but with a less robust semantic):

 - https://blog.codeship.com/optimists-guide-pessimistic-library-versioning

And Python is currently planing to use an `~=` operator:

 - https://www.python.org/dev/peps/pep-0440/#compatible-release

@hvr hvr force-pushed the hvr:pr/caret-version-range-op branch from 5036c46 to 0f2193a Sep 1, 2016

@hvr

This comment has been minimized.

Copy link
Member

hvr commented Sep 1, 2016

I've changed the syntax from ^> to ^>= because it's more accurate/self-descriptive (since it's more evident that ^+>= translates to < + >= than the original syntax, and it's easier to convert between one and the other in a text-editor) in my opinion.

@23Skidoo changelog entry added

@phadej finally brought myself to try to come up with a simple parser test... getting there took longer than it should have...

@23Skidoo

This comment has been minimized.

Copy link
Member

23Skidoo commented Sep 1, 2016

Thanks! So I think this can be merged once Travis is green.

@hvr hvr merged commit c7f788a into haskell:master Sep 1, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ezyang ezyang modified the milestones: Cabal 2.0, 2.0 (planned for next feature release) Sep 6, 2016

@hvr hvr deleted the hvr:pr/caret-version-range-op branch Aug 10, 2017

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