@@ -1,42 +0,0 @@
1−module Cabal2Nix.Pretty where
2−
3−import Text.PrettyPrint
4−
5−-- Pretty-printing helpers for Nix expressions.
6−
7−attr :: String -> Doc -> Doc
8−attr n v = text n <+> equals <+> v <> semi
9−
10−onlyIf :: [a] -> Doc -> Doc
11−onlyIf p d = if not (null p) then d else empty
12−
13−boolattr :: String -> Bool -> Bool -> Doc
14−boolattr n p v = if p then attr n (bool v) else empty
15−
16−listattr :: String -> [String] -> Doc
17−listattr n vs = onlyIf vs $
18− sep [ text n <+> equals <+> lbrack,
19− nest 2 $ fsep $ map text vs,
20− rbrack <> semi
21− ]
22−
23−bool :: Bool -> Doc
24−bool True = text "true"
25−bool False = text "false"
26−
27−string :: String -> Doc
28−string = doubleQuotes . text
29−
30−version :: [Int] -> Doc
31−version = doubleQuotes . hcat . punctuate (text ".") . map int
32−
33−prepunctuate :: Doc -> [Doc] -> [Doc]
34−prepunctuate _ [] = []
35−prepunctuate p (d:ds) = d : map (p <>) ds
36−
37−funargs :: [Doc] -> Doc
38−funargs xs = sep [
39− lbrace <+> (fcat $ prepunctuate (comma <> text " ") $
40− map (nest 2) xs),
41− rbrace <> colon
42− ]