git.iko.soy/typeable/pandoc
on 1.13.1 help sign in
typeable/pandoc/Interact.hs
34 lines 1.3 kB history raw
1-- Get an interactive shell with the right packages to load
2-- pandoc modules.
4-- To use:
5-- runghc Interact.hs
6-- then,
7-- :l Text/Pandoc.hs
8-- (or whichever package you like)
10-- You must have first done a 'cabal configure' or 'cabal install'
12-- Note: Interact.hs doesn't work with Cabal >= 1.18. I recommend
13-- using cabal sandboxes and the new 'cabal repl' command if you are
14-- using a recent version.
16import System.Process
17import Distribution.Simple.LocalBuildInfo
18import Distribution.Package
19import Distribution.Version
20import Data.List (intercalate)
22main = do
23 setupConfig' <- readFile "dist/setup-config"
24 let setupConfig = read $ unlines $ drop 1 $ lines setupConfig'
25 let (Just (ComponentLocalBuildInfo { componentPackageDeps = deps })) = libraryConfig setupConfig
26 let packageSpecs = map (toPackageSpec . snd) deps
27 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
28 print args
29 ph <- runProcess "ghci" args (Just "src") Nothing Nothing Nothing Nothing
30 waitForProcess ph
32toPackageSpec pkg = pkgN ++ "-" ++ pkgV
33 where (PackageName pkgN) = pkgName pkg
34 pkgV = intercalate "." $ map show $ versionBranch $ pkgVersion pkg