git.iko.soy/typeable/pandoc
on master help sign in
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).

commitb950503fd82e9cc114e10860c234eb4b10d1ce27 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 22 Dec 2010, 21:06 (16 years ago) parentc08ca6f
1 file changed+30
Interact.hs+30
Interact.hsnew file+30
@@ -0,0 +1,30 @@
1+-- Get an interactive shell with the right packages to load
2+-- pandoc modules.
3+
4+-- To use:
5+-- runghc Interact.hs
6+-- then,
7+-- :l Text/Pandoc.hs
8+-- (or whichever package you like)
9+
10+-- You must have first done a 'cabal configure' or 'cabal install'
11+
12+import System.Process
13+import Distribution.Simple.LocalBuildInfo
14+import Distribution.Package
15+import Distribution.Version
16+import Data.List (intercalate)
17+
18+main = do
19+ setupConfig' <- readFile "dist/setup-config"
20+ let setupConfig = read $ unlines $ drop 1 $ lines setupConfig'
21+ let (Just (ComponentLocalBuildInfo { componentPackageDeps = deps })) = libraryConfig setupConfig
22+ let packageSpecs = map (toPackageSpec . snd) deps
23+ let args = ["-cpp","-i../dist/build/autogen"] ++ concatMap (\p -> ["-package",p]) packageSpecs
24+ print args
25+ ph <- runProcess "ghci" args (Just "src") Nothing Nothing Nothing Nothing
26+ waitForProcess ph
27+
28+toPackageSpec pkg = pkgN ++ "-" ++ pkgV
29+ where (PackageName pkgN) = pkgName pkg
30+ pkgV = intercalate "." $ map show $ versionBranch $ pkgVersion pkg