From 13d876bab3615174eb825d7b8048a0dd74eaebb8 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Tue, 19 Jan 2021 11:30:41 +0100 Subject: Enhance nested TransCo pretty-printing Nested TransCo were printed with a lot of indentation, e.g.: `cast` (Sub (Sym (Foo.D:R:Index[0] _N <'[]>_N)) ; ((Index (Sym (SubDef (<1>_N, <1>_N))) <'[Bool]>_N)_R ; ... With this patch we print them as follows: `cast` (Sub (Sym (Foo.D:R:Index[0] _N <'[]>_N)) ; (Index (Sym (SubDef (<1>_N, <1>_N))) <'[Bool]>_N)_R ; Sub (Sym (Foo.D:R:Index[1] <1>_N _N <'[Bool]>_N)) ; (Index (Sym (SubDef (<2>_N, <1>_N))) <'[Int, Bool]>_N)_R --- compiler/GHC/Iface/Type.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/GHC/Iface/Type.hs b/compiler/GHC/Iface/Type.hs index e87998dd37..1e83aa2f10 100644 --- a/compiler/GHC/Iface/Type.hs +++ b/compiler/GHC/Iface/Type.hs @@ -1681,8 +1681,11 @@ ppr_co ctxt_prec (IfaceAxiomInstCo n i cos) ppr_co ctxt_prec (IfaceSymCo co) = ppr_special_co ctxt_prec (text "Sym") [co] ppr_co ctxt_prec (IfaceTransCo co1 co2) - = maybeParen ctxt_prec opPrec $ - ppr_co opPrec co1 <+> semi <+> ppr_co opPrec co2 + -- chain nested TransCo + = let ppr_trans (IfaceTransCo c1 c2) = semi <+> ppr_co topPrec c1 : ppr_trans c2 + ppr_trans c = [semi <+> ppr_co opPrec c] + in maybeParen ctxt_prec opPrec $ + vcat (ppr_co topPrec co1 : ppr_trans co2) ppr_co ctxt_prec (IfaceNthCo d co) = ppr_special_co ctxt_prec (text "Nth:" <> int d) [co] ppr_co ctxt_prec (IfaceLRCo lr co) -- cgit v1.2.1