summaryrefslogtreecommitdiff
path: root/compiler/hsSyn
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2010-06-15 07:04:09 +0000
committersimonpj@microsoft.com <unknown>2010-06-15 07:04:09 +0000
commit617a845f9574185f71db0cad7cfcb2e54fcb9db4 (patch)
tree7812ee937eedfa5c8f17d5164d12bb9f289f8e11 /compiler/hsSyn
parenta3ed66ebc38894332bcdc28b5ae3085de42b5955 (diff)
downloadhaskell-617a845f9574185f71db0cad7cfcb2e54fcb9db4.tar.gz
Comments, and improvement to pretty-printing of HsGroup
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r--compiler/hsSyn/HsBinds.lhs4
-rw-r--r--compiler/hsSyn/HsDecls.lhs27
2 files changed, 20 insertions, 11 deletions
diff --git a/compiler/hsSyn/HsBinds.lhs b/compiler/hsSyn/HsBinds.lhs
index c4d38fd7a3..5709e58238 100644
--- a/compiler/hsSyn/HsBinds.lhs
+++ b/compiler/hsSyn/HsBinds.lhs
@@ -66,11 +66,11 @@ data HsLocalBindsLR idL idR -- Bindings in a 'let' expression
type HsValBinds id = HsValBindsLR id id
data HsValBindsLR idL idR -- Value bindings (not implicit parameters)
- = ValBindsIn -- Before typechecking
+ = ValBindsIn -- Before renaming
(LHsBindsLR idL idR) [LSig idR] -- Not dependency analysed
-- Recursive by default
- | ValBindsOut -- After renaming
+ | ValBindsOut -- After renaming
[(RecFlag, LHsBinds idL)] -- Dependency analysed, later bindings
-- in the list may depend on earlier
-- ones.
diff --git a/compiler/hsSyn/HsDecls.lhs b/compiler/hsSyn/HsDecls.lhs
index dc4bac71ee..dff8ce7301 100644
--- a/compiler/hsSyn/HsDecls.lhs
+++ b/compiler/hsSyn/HsDecls.lhs
@@ -221,16 +221,25 @@ instance OutputableBndr name => Outputable (HsGroup name) where
hs_fords = foreign_decls,
hs_defds = default_decls,
hs_ruleds = rule_decls })
- = vcat [ppr_ds fix_decls, ppr_ds default_decls,
- ppr_ds deprec_decls, ppr_ds ann_decls,
- ppr_ds rule_decls,
- ppr val_decls,
- ppr_ds tycl_decls, ppr_ds inst_decls,
- ppr_ds deriv_decls,
- ppr_ds foreign_decls]
+ = vcat_mb empty
+ [ppr_ds fix_decls, ppr_ds default_decls,
+ ppr_ds deprec_decls, ppr_ds ann_decls,
+ ppr_ds rule_decls,
+ if isEmptyValBinds val_decls
+ then Nothing
+ else Just (ppr val_decls),
+ ppr_ds tycl_decls, ppr_ds inst_decls,
+ ppr_ds deriv_decls,
+ ppr_ds foreign_decls]
where
- ppr_ds [] = empty
- ppr_ds ds = blankLine $$ vcat (map ppr ds)
+ ppr_ds [] = Nothing
+ ppr_ds ds = Just (vcat (map ppr ds))
+
+ vcat_mb :: SDoc -> [Maybe SDoc] -> SDoc
+ -- Concatenate vertically with white-space between non-blanks
+ vcat_mb _ [] = empty
+ vcat_mb gap (Nothing : ds) = vcat_mb gap ds
+ vcat_mb gap (Just d : ds) = gap $$ d $$ vcat_mb blankLine ds
data SpliceDecl id
= SpliceDecl -- Top level splice