From qinka at live.com Wed Jul 19 01:50:30 2017 From: qinka at live.com (Lee John) Date: Wed, 19 Jul 2017 01:50:30 +0000 Subject: mutex-flags Message-ID: 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 ... From oleg.grenrus at iki.fi Wed Jul 19 09:08:02 2017 From: oleg.grenrus at iki.fi (Oleg Grenrus) Date: Wed, 19 Jul 2017 12:08:02 +0300 Subject: mutex-flags In-Reply-To: References: Message-ID: <11d97d71-c419-e43d-d54d-d63f2f5e2377@iki.fi> Hi, I proposed multiway flags about a year ago [1]. With that you could write: flag xx values: a, b, c, d if flag(xx == a) build-depends: xx-a if flag(xx == b) build-depends: xx-b if flag(xx == c) build-depends: xx-c if flag(xx == d) build-depends: xx-d The benefits over your proposal, is that there's only one flag! The alternatives mentioned in the issue [1] consider only automatic flags, but now as I think about, manual multiway flags can be useful too. --- For complex "multiway" selection example see: http://hackage.haskell.org/package/functor-classes-compat-1/functor-classes-compat.cabal The idea is that with two flags (transformers-1 and transformers-2) you have already 4 combinations, so you don't need 4 flags. That's not intuitive interface for manual flags though. (There the "elif" syntax would help, which I'll add to Cabal for GHC-8.4) --- Another way to write "mutex" is (with three flags: a, b, c): -- at least one: if !(flag(a) || flag(b) || flag(c)) -- at most one: if flag(a) && flag(b) build-depends: base<0 if flag(a) && flag(c) build-depends: base<0 if flag(b) && flag(c) build-depends: base<0 That's tedious to go thru all pairs, but quite straightforward. And can live in a separate block from where the actual flag-logic is defined. The same trick can be used with two-flags for three options: if flag(xx-1) if flag(xx-2) -- option 1 else -- option 2 else if flag(xx-2) -- option 3 else build-depends: base<0 It's also discussed to add explicit fail: Unsupported configuration so we don't need to use unsatisfiable "base<0" constraint. - Oleg [1]: https://github.com/haskell/cabal/issues/3526 On 19.07.2017 04:50, Lee John wrote: > 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 > ... > _______________________________________________ > cabal-devel mailing list > cabal-devel at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/cabal-devel -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: OpenPGP digital signature URL: From carter.schonwald at gmail.com Fri Jul 28 19:10:58 2017 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Fri, 28 Jul 2017 19:10:58 +0000 Subject: Documentation true flag ignored on caba install l 2.0 branch Message-ID: This looks like the last engineering issue for 2.0 release. Is there any way to help out? I've patched my local build to just have the flag set to true by default in the source code ... but I sense we don't want that ;) -------------- next part -------------- An HTML attachment was scrubbed... URL: