Ticket #209 (new enhancement)

Opened 11 months ago

Last modified 4 weeks ago

Implement "package()" configurations predicate

Reported by: duncan Assigned to: nominolo
Priority: normal Milestone: Cabal-1.8
Component: Cabal library Version: 1.2.3.0
Severity: normal Keywords:
Cc: Difficulty: hard (< 1 day)
GHC Version: 6.8.2 Platform:

Description

We often have to write things like:

flag splitBase
  description: Choose the new smaller, split-up base package.
library
  if flag(splitBase)
    build-depends: base >= 3, containers
  else
    build-depends: base < 3

Which is verbose and annoying. It would be nicer to say:

library
  build-depends: base
  if package(base >= 3)
    build-depends: containers

This is syntactic sugar only. It translates into the existing constructs so no new behaviour is being introduced. It would translate into:

flag _1

library
  build-depends: base
  if flag(_1)
    build-depends: base >= 3
    build-depends: containers
  else
    build-depends: base < 3

It is described in more detail in this thread: http://www.haskell.org/pipermail/cabal-devel/2007-October/001189.html http://www.haskell.org/pipermail/cabal-devel/2007-November/001336.html

Change History

01/24/08 07:59:46 changed by duncan

  • difficulty changed from normal to hard (< 1 day).
  • platform deleted.
  • milestone set to Cabal-1.4.

02/04/08 17:22:03 changed by duncan

  • owner set to nominolo.

(follow-up: ↓ 4 ) 03/06/08 17:01:39 changed by ross@soi.city.ac.uk

Another variant would be to support anonymous flags directly, allowing a syntax like:

library
  if _
    build-depends: base >= 3, containers
  else
    build-depends: base < 3

(in reply to: ↑ 3 ) 03/06/08 17:29:21 changed by duncan

Replying to ross@soi.city.ac.uk:

Another variant would be to support anonymous flags directly

True though I suspect it looks a bit weird to the uninitiated. We know to read the conditional syntax as an implication constraint which can be applied in either direction but I suspect many people read it in a directed functional way. I have a feeling that the anonymous flag would really throw people :-)

Perhaps we should ask opinions on the libraries list.

03/19/08 15:25:46 changed by duncan

  • milestone changed from Cabal-1.4 to Cabal-1.6.

Punting.

10/09/08 10:15:49 changed by duncan

  • milestone changed from Cabal-1.6 to Cabal-1.8.

11/08/08 08:01:33 changed by duncan

Of course if we want it for build-depends then we may also want it for other dependencies like pkgconfig-depends or build-tools. So we should bear that in mind in designing a syntax.

For example darcs might like to use:

  pkgconfig-depends: libcurl
  if pkgconfig-depends(libcurl >= 7.19.1)
      -- curl 7.19.1 has bug-free pipelining
      cpp-options: -DCURL_PIPELINING_DEFAULT

as syntactic sugar for:

flag curl-pipelining
  description: Use libcurl's HTTP pipelining.

...

  pkgconfig-depends: libcurl
  if flag(curl-pipelining)
    -- curl 7.19.1 has bug-free pipelining
    pkgconfig-depends: libcurl >= 7.19.1
    cpp-options: -DCURL_PIPELINING_DEFAULT
  else
    pkgconfig-depends: libcurl < 7.19.1

Note of course the above doesn't work well yet anyway, it needs #342 to be implemented.