mutex-flags

Lee John qinka at live.com
Wed Jul 19 01:50:30 UTC 2017


I think the mutex flags might be needed. For example, if my program use accelerate and I want my program can use both of cuda, llvm, (etc) as the backend for accelerating, I need to write a lot of if-statements in cabal file to control that there will be only one backend to be used. So I think that mutex-flags might be useful.

For example:

…
flag a
default: False
flag b
default: False
flag c
default: False
flag d
default: False
...
exec…
…
if flag(a) && !flag(b) && !flag(c) && !flag(d)
	build-depends: xx-a

…
if !flag(a) && flag(b) && !flag(c) && !flag(d)
	build-depends: xx-b

…
if !flag(a) && !flag(b) && flag(c) && !flag(d)
	build-depends: xx-c

…
if !flag(a) && !flag(b) && !flag(c) 
	build-depends: xx-d
…

The above codes are also hard to maintain or extend. Following codes will better.

…
flag a
default: False
flag b
default: False
flag c
default: False
flag d
default: False
mutex 
flags: a b c d
default: d
…

if flag(a)
build-depends: xx-a

if flag(b)
build-depends: xx-b

if flag(c)
build-depends: xx-c

if flag(d)
build-depends: xx-d
...


More information about the cabal-devel mailing list