-
Notifications
You must be signed in to change notification settings - Fork 103
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
Allow specifying dependencies as a hash #193
Conversation
@tfausak Hey, sorry for the late reply (I was offline for a while).
This syntax is actually what convinced me in favor of adding this feature. In addition, I was hopping that it will be possible to tighten (or loosen) constraints for specific dependencies, e.g.: dependencies:
base: 4.*
tests:
...
dependencies:
base: '>= 4.3' What exactly do you mean with "hard" when it comes to parsing constraints? My assumption was that depending on |
I said that parsing constraints would be hard because right now the dependency strings are simply passed through to the Cabal file. Parsing the constraints will be a little bit bigger of a change, but it's definitely doable. Would later constraints be "and"ed together with earlier ones? In your example, that would end up as |
Cabal solves dependencies for a package as a whole (with intersection-semantics for constraints from different sections, which is the same as This will give us the exact same semantics in most cases. The only exception I see is when you override a global dependency in all sections of a package, e.g.: dependencies:
base: '>= 4'
library:
dependencies:
base: '< 5'
...
tests:
spec:
dependencies:
base: '>= 4.3' which is not particularly DRY in the first place and better expressed as dependencies:
base: 4.*
tests:
spec:
dependencies:
base: '>= 4.3' (As a side note, as I understand it, it's never useful to specify different constraints for
Can you come up with a use case? @tfausak big sorry again for the delay! I implemented constraint parsing and changed the internal representation from a list to a |
Once we are through with this, I'm also happy to revisit #91 and see what we can cherry-pick from npm/bundler. |
I'll take another look at this today. Your changes look great and lay a nice foundation for what I want to do here. I'll probably open another PR to avoid gnarly merge conflicts. |
Closing in favor of #198. |
This pull request fixes #186. It changes the dependencies to allow hash values specifying the package as the key and the constraint as the value. Here are some allowable dependencies:
In #186 I originally suggested that the
==
constraint be implied if no constraints were given. In other words,base: 4.10.0.0
would meanbase ==4.10.0.0
. I chose not to implement that because it would require parsing constraints, which is hard.