[cabal] Extract simple static information from PackageDescription
Daniel Trstenjak
daniel.trstenjak at gmail.com
Fri Nov 6 20:37:56 UTC 2015
Hi Jakob,
you might like the cabal-lenses[1] library.
Getting 'hs-source-dirs' from all sections of the cabal file (library,
executable, ...) and evaluating the conditionals in the cabal file
(considering the default value of flags and the current platform), you
should be able to write:
import Control.Lens -- from the lens library
import CabalLenses -- from the cabal-lenses library
hsSourceDirs :: GenericPackageDescription -> [String]
hsSourceDirs pkgDesc = pkgDesc ^.. allBuildInfo . traversed . hsSourceDirsL
You can also specify[2] which section you like to read or how flags
for the conditionals should be set.
If you only need a command line programming for the reading of 'hs-source-dirs',
then there's cabal-cargs[3]. The above example:
cabal-cargs --only=hs_source_dirs --format=pure
Greetings,
Daniel
[1] https://hackage.haskell.org/package/cabal-lenses-0.4.7
[2] https://hackage.haskell.org/package/cabal-lenses-0.4.5/docs/CabalLenses-Traversals-BuildInfo.html
[3] https://hackage.haskell.org/package/cabal-cargs
More information about the Libraries
mailing list