5 data Package = Package {
6 import_dirs :: [String],
7 library_dirs :: [String],
9 include_dirs :: [String],
10 c_includes :: [String],
11 package_deps :: [String],
12 extra_ghc_opts :: [String],
13 extra_cc_opts :: [String],
14 extra_ld_opts :: [String]
18 listPkgs :: [(String,Package)] -> String
19 listPkgs pkgs = render (fsep (punctuate comma (map (text . fst) pkgs)))
21 dumpPackages :: [(String,Package)] -> String
23 render (brackets (vcat (punctuate comma (map dumpPkg pkgs))))
25 dumpPkg :: (String,Package) -> Doc
27 parens (hang (text (show name) <> comma) 2 (dumpPkgGuts pkg))
29 dumpPkgGuts :: Package -> Doc
31 text "Package" $$ nest 3 (braces (
32 sep (punctuate comma [
33 dumpField "import_dirs" (import_dirs pkg),
34 dumpField "library_dirs" (library_dirs pkg),
35 dumpField "libraries" (libraries pkg),
36 dumpField "include_dirs" (include_dirs pkg),
37 dumpField "c_includes" (c_includes pkg),
38 dumpField "package_deps" (package_deps pkg),
39 dumpField "extra_ghc_opts" (extra_ghc_opts pkg),
40 dumpField "extra_cc_opts" (extra_cc_opts pkg),
41 dumpField "extra_ld_opts" (extra_ld_opts pkg)
44 dumpField :: String -> [String] -> Doc
46 hang (text name <+> equals) 2
47 (brackets (sep (punctuate comma (map (text . show) val))))