aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-12-22 21:06:23 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2010-12-22 21:06:23 -0800
commitb950503fd82e9cc114e10860c234eb4b10d1ce27 (patch)
treebe3d258378ba84457e75e2465738b19a912a35e8
parentc08ca6fa6d58c6a52c93b126d1a704b8202f9a36 (diff)
downloadpandoc-b950503fd82e9cc114e10860c234eb4b10d1ce27.tar.gz
Added Interact.hs to make it easier to use ghci while developing.
Interact.hs loads ghci from the src directory, specifying all the options needed to load pandoc modules (including specific package dependencies, which it gets by parsing dist/setup-config).
-rw-r--r--Interact.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Interact.hs b/Interact.hs
new file mode 100644
index 000000000..8fa7b5b3b
--- /dev/null
+++ b/Interact.hs
@@ -0,0 +1,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 = ["-cpp","-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