diff options
| author | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2006-09-18 23:00:46 +0000 |
|---|---|---|
| committer | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2006-09-18 23:00:46 +0000 |
| commit | 5537ba01a8cd93ea209ef67f3431d9f5f9cd9d34 (patch) | |
| tree | 37098e91cbcc3ce7ed047b8f01625ed31d5273b4 | |
| parent | ac9c1e5de9629103a125e0515dcee2466ff898a7 (diff) | |
| download | haskell-5537ba01a8cd93ea209ef67f3431d9f5f9cd9d34.tar.gz | |
Improve pretty printing for indexed type decls
Wed Aug 16 17:01:59 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au>
* Improve pretty printing for indexed type decls
| -rw-r--r-- | compiler/hsSyn/HsDecls.lhs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/compiler/hsSyn/HsDecls.lhs b/compiler/hsSyn/HsDecls.lhs index 2515c1af7a..2128ad399f 100644 --- a/compiler/hsSyn/HsDecls.lhs +++ b/compiler/hsSyn/HsDecls.lhs @@ -517,19 +517,23 @@ instance OutputableBndr name dcolon <+> pprKind kind where typeMaybeIso = if iso - then ptext SLIT("type iso") - else ptext SLIT("type") + then ptext SLIT("type family iso") + else ptext SLIT("type family") ppr (TySynonym {tcdLName = ltycon, tcdTyVars = tyvars, tcdTyPats = typats, tcdSynRhs = mono_ty}) - = hang (ptext SLIT("type") <+> pp_decl_head [] ltycon tyvars typats <+> + = hang (ptext SLIT("type") <+> + (if isJust typats then ptext SLIT("instance") else empty) <+> + pp_decl_head [] ltycon tyvars typats <+> equals) 4 (ppr mono_ty) ppr (TyData {tcdND = new_or_data, tcdCtxt = context, tcdLName = ltycon, tcdTyVars = tyvars, tcdTyPats = typats, tcdKindSig = mb_sig, tcdCons = condecls, tcdDerivs = derivings}) - = pp_tydecl (ppr new_or_data <+> + = pp_tydecl (null condecls && isJust mb_sig) + (ppr new_or_data <+> + (if isJust typats then ptext SLIT("instance") else empty) <+> pp_decl_head (unLoc context) ltycon tyvars typats <+> ppr_sig mb_sig) (pp_condecls condecls) @@ -573,12 +577,14 @@ pp_condecls cs@(L _ ConDecl{ con_res = ResTyGADT _ } : _) -- In GADT syntax pp_condecls cs -- In H98 syntax = equals <+> sep (punctuate (ptext SLIT(" |")) (map ppr cs)) -pp_tydecl pp_head pp_decl_rhs derivings +pp_tydecl True pp_head pp_decl_rhs derivings + = pp_head +pp_tydecl False pp_head pp_decl_rhs derivings = hang pp_head 4 (sep [ - pp_decl_rhs, - case derivings of - Nothing -> empty - Just ds -> hsep [ptext SLIT("deriving"), parens (interpp'SP ds)] + pp_decl_rhs, + case derivings of + Nothing -> empty + Just ds -> hsep [ptext SLIT("deriving"), parens (interpp'SP ds)] ]) instance Outputable NewOrData where |
