haskell / haskell/cabal

VersionRange abstract, role of VersionRangeF?

Open
#9,101 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

While writing tools that deal with dependency version bounds, I am a bit struggling with the fact that `VersionRange` is abstract (the constructors are only exported from an `.Internal` module, so probably I am not supposed to use that?

For example, I’d like to append a disjunction at the end (`\vr' -> unionMajorBounds vr' vr`). But if I do that and `vr` is already a disjunction, it’s associated the wrong way, and I get ugly changes like
```
- bytestring ^>=0.10.12.0 || ^>=0.11.3.1,
+ bytestring (^>=0.10.12.0 || ^>=0.11.3.1) || ^>=0.12.0.0,
```

I could implement a smarter “append” function that reassociates, if I can traverse the data structure directly.

Since 2.2 there is also the [F-Algebra](https://hackage.haskell.org/package/Cabal-syntax-3.10.1.0/docs/Distribution-Types-VersionRange.html#t:VersionRangeF), which has its constructors exported. Does that mean should use use that detour if I want to write VersionRange-modifying functions?

(For this particular case, maybe [`normaliseVersionRange`](https://hackage.haskell.org/package/Cabal-syntax-3.10.1.0/docs/src/Distribution.Types.VersionRange.html#normaliseVersionRange) should reassociate disjunctions, to give API users one less reasons to look into VersionRanges?)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.