git.iko.soy/typeable/cabal2nix
on master help sign in
Adapt pretty-printing to coding guidelines. Closes #9.
commitfc3a2ad7433731508a52cb9f3061c602625dccaf authorAndres Loeh <mail@andres-loeh.de> dateMon 8 Aug 2011, 13:51 (15 years ago) parentfcf14da
1 file changed+13−4
src/Cabal2Nix/Package.hs+13−4
src/Cabal2Nix/Package.hs+13−4
@@ -39,14 +39,23 @@ data Pkg = Pkg PkgName
3939 PkgMaintainers
4040 deriving (Show)
4141
42+prepunctuate :: Doc -> [Doc] -> [Doc]
43+prepunctuate _ [] = []
44+prepunctuate p (d:ds) = d : map (p <>) ds
45+
46+
4247showNixPkg :: Pkg -> String
4348showNixPkg (Pkg name ver sha256 url desc lic deps tools libs platforms maintainers) = render doc
4449 where
45− doc = braces (fsep $ punctuate comma $
46− map text ("cabal" : pkgBuildTools ++ pkgDeps)) <+>
47− colon $$ text "" $$
50+ doc = sep [
51+ lbrace <+> (fcat $ prepunctuate (comma <> text " ") $
52+ map (nest 2 . text)
53+ ("cabal" : pkgBuildTools ++ pkgDeps)),
54+ rbrace <> colon
55+ ] $$
4856 vcat [
49− text "cabal.mkDerivation" <+> lparen <> text "self" <+>
57+ text "",
58+ text "cabal.mkDerivation" <+> lparen <> text "self" <>
5059 colon <+> lbrace,
5160 nest 2 $ vcat [
5261 attr "pname" $ doubleQuotes (text name),