[commit: ghc] tc-untouchables: Improve pretty printing for coercions (exp transistivity chains) (c35c5d0)
Simon Peyton Jones <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cvs.ghc |
|---|---|
| Message-ID | <[email protected]> |
Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : tc-untouchables http://hackage.haskell.org/trac/ghc/changeset/c35c5d0262bfb18e58e7fd249c03e23cc9ff64c9 >--------------------------------------------------------------- commit c35c5d0262bfb18e58e7fd249c03e23cc9ff64c9 Author: Simon Peyton Jones <[email protected]> Date: Mon Oct 1 10:31:25 2012 +0100 Improve pretty printing for coercions (exp transistivity chains) >--------------------------------------------------------------- compiler/types/Coercion.lhs | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs index fab8fa5..4599ddf 100644 --- a/compiler/types/Coercion.lhs +++ b/compiler/types/Coercion.lhs @@ -418,10 +418,11 @@ ppr_co p co@(ForAllCo {}) = ppr_forall_co p co ppr_co _ (CoVarCo cv) = parenSymOcc (getOccName cv) (ppr cv) ppr_co p (AxiomInstCo con cos) = pprTypeNameApp p ppr_co (getName con) cos -ppr_co p (TransCo co1 co2) = maybeParen p FunPrec $ - ppr_co FunPrec co1 - <+> ptext (sLit ";") - <+> ppr_co FunPrec co2 +ppr_co p co@(TransCo {}) = maybeParen p FunPrec $ + case trans_co_list co [] of + [] -> panic "ppr_co" + (co:cos) -> sep ( ppr_co FunPrec co + : [ char ';' <+> ppr_co FunPrec co | co <- cos]) ppr_co p (InstCo co ty) = maybeParen p TyConPrec $ pprParendCo co <> ptext (sLit "@") <> pprType ty @@ -431,6 +432,10 @@ ppr_co p (SymCo co) = pprPrefixApp p (ptext (sLit "Sym")) [pprParendCo c ppr_co p (NthCo n co) = pprPrefixApp p (ptext (sLit "Nth:") <> int n) [pprParendCo co] ppr_co p (LRCo sel co) = pprPrefixApp p (ppr sel) [pprParendCo co] +trans_co_list :: Coercion -> [Coercion] -> [Coercion] +trans_co_list (TransCo co1 co2) cos = trans_co_list co1 (trans_co_list co2 cos) +trans_co_list co cos = co : cos + instance Outputable LeftOrRight where ppr CLeft = ptext (sLit "Left") ppr CRight = ptext (sLit "Right")