Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 30 lines (25 sloc) 1.122 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
-- Get an interactive shell with the right packages to load
-- pandoc modules.

-- To use:
-- runghc Interact.hs
-- then,
-- :l Text/Pandoc.hs
-- (or whichever package you like)

-- You must have first done a 'cabal configure' or 'cabal install'

import System.Process
import Distribution.Simple.LocalBuildInfo
import Distribution.Package
import Distribution.Version
import Data.List (intercalate)

main = do
  setupConfig' <- readFile "dist/setup-config"
  let setupConfig = read $ unlines $ drop 1 $ lines setupConfig'
  let (Just (ComponentLocalBuildInfo { componentPackageDeps = deps })) = libraryConfig setupConfig
  let packageSpecs = map (toPackageSpec . snd) deps
  let args = ["-optP-include", "-optP../dist/build/autogen/cabal_macros.h","-cpp","-I../dist/build/autogen","-i../dist/build/autogen"] ++ concatMap (\p -> ["-package",p]) packageSpecs
  print args
  ph <- runProcess "ghci" args (Just "src") Nothing Nothing Nothing Nothing
  waitForProcess ph

toPackageSpec pkg = pkgN ++ "-" ++ pkgV
  where (PackageName pkgN) = pkgName pkg
        pkgV = intercalate "." $ map show $ versionBranch $ pkgVersion pkg
Something went wrong with that request. Please try again.