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