haskell / haskell/cabal

Support || (or) in build-depends

Open
#2,033 4 comments 0 reactions 0 assignees View on GitHub
Cabal: file format Cabal: other type: discussion type: enhancement
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

Currently build-depends don't support "or" between package constraints. All the package constraints are implicitly and-ed together. This means that users have to encode or-constraints using flags, which is verbose and can be more error prone (e.g. users might set the flag to manual).

Consider the planned split of network into network and network-uri, where the `Network.URI` module is moved out of network into network-uri. Users that want to use that module need to specify the following dependency:

```
flag network-uri
description: Get Network.URI from the network-uri package.
default: True

library
if flag(network-uri)
build-depends:
network >= 2.6 && network-uri >= 2.6
else
build-depends:
network < 2.6
```

What if we could instead write

```
library
if flag(network-uri)
build-depends:
network >= 2.6 && network-uri >= 2.6 || network < 2.6
```

(The syntax probably need to be different, as build-depends already supports `||`, with a different meaning.)

The implementation could still be in terms of flags.

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.