dynamic-cabal: dynamic-cabal

[ bsd3, distribution, library ] [ Propose Tags ]

dynamic-cabal


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.2, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5
Dependencies base (>=4.4 && <5), containers, data-default, directory, filepath, ghc, ghc-paths, haskell-generate, haskell-src-exts, time, void [details]
License BSD-3-Clause
Copyright Copyright (C) 2013 Benno Fünfstück
Author Benno Fünfstück
Maintainer Benno Fünfstück <benno.fuenfstueck@gmail.com>
Category Distribution
Home page http://github.com/bennofs/dynamic-cabal/
Bug tracker http://github.com/bennofs/dynamic-cabal/issues
Source repo head: git clone https://github.com/bennofs/dynamic-cabal.git
Uploaded by BennoFuenfstueck at 2014-08-14T19:02:31Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 16568 total (22 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]

Readme for dynamic-cabal-0.3.2

[back to package description]

dynamic-cabal

Build Status

If you've ever used Cabal together with the GHC-API, you know the problem. Because GHC depends on a version of Cabal, which is often outdated, there is no way to parse the setup-config file generated by newer cabal versions. This library attemps to solve the problem by dynamically generating code that performs the action you want, and then compiling and loading that with GHC. With this method, you don't need to depend on Cabal at compile time and so you can use any version of Cabal.

Usage

Currently, the library only allows two queries: Getting the targets (along with their dependencies, ghc options, etc) and the package databases. The first is easily achieved using the targets query provided by the library. To run the query, you can use the runQuery function, which takes the path to the setup-config file as an argument. For example, the following little program prints out the names of all test suites, when run in a configured cabal project root directory:

import Distribution.Client.Dynamic

main :: IO ()
main = do
  tgs <- runQuery (on localPkgDesc targets) "dist/setup-config"
  mapM_ putStrLn [ n | TestSuite n <- map name tgs ]

Because targets works on a PackageDescription, on localPkgDesc is used to get the current PackageDescription.

Contributing

At the moment, I only implemented the functions I need myself. If you have more functions you want to implement, just send a pull request or open an issue.