diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-10-03 15:58:13 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-10-04 15:37:58 +0100 |
commit | 37ef7031b95c97e7c8bc1d14bc95554a3bac2873 (patch) | |
tree | 62d7205455558129b826ce9d252b07406b2114ec /compiler/iface | |
parent | 9ebfa03d9e9cbf79f698b5d4bd39e799e4e9a02c (diff) | |
download | haskell-37ef7031b95c97e7c8bc1d14bc95554a3bac2873.tar.gz |
Better pretty-printing of forall types
Currently forall-types with a lot of type variables,
or type variables with big kinds, are pretty-printed too
horizontally, and dribble off to the right in an illegible
way.
This patch treats the type variables as a group, and uses
'fsep' to lay them out decently.
Diffstat (limited to 'compiler/iface')
-rw-r--r-- | compiler/iface/IfaceType.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/iface/IfaceType.hs b/compiler/iface/IfaceType.hs index 23b09dab7a..264dfa0c57 100644 --- a/compiler/iface/IfaceType.hs +++ b/compiler/iface/IfaceType.hs @@ -929,9 +929,10 @@ ppr_iface_forall_part show_forall tvs ctxt sdoc pprIfaceForAll :: [IfaceForAllBndr] -> SDoc pprIfaceForAll [] = empty pprIfaceForAll bndrs@(Bndr _ vis : _) - = add_separator (forAllLit <+> doc) <+> pprIfaceForAll bndrs' + = sep [ add_separator (forAllLit <+> fsep docs) + , pprIfaceForAll bndrs' ] where - (bndrs', doc) = ppr_itv_bndrs bndrs vis + (bndrs', docs) = ppr_itv_bndrs bndrs vis add_separator stuff = case vis of Required -> stuff <+> arrow @@ -943,12 +944,12 @@ pprIfaceForAll bndrs@(Bndr _ vis : _) -- No anonymous binders here! ppr_itv_bndrs :: [IfaceForAllBndr] -> ArgFlag -- ^ visibility of the first binder in the list - -> ([IfaceForAllBndr], SDoc) + -> ([IfaceForAllBndr], [SDoc]) ppr_itv_bndrs all_bndrs@(bndr@(Bndr _ vis) : bndrs) vis1 | vis `sameVis` vis1 = let (bndrs', doc) = ppr_itv_bndrs bndrs vis1 in - (bndrs', pprIfaceForAllBndr bndr <+> doc) - | otherwise = (all_bndrs, empty) -ppr_itv_bndrs [] _ = ([], empty) + (bndrs', pprIfaceForAllBndr bndr : doc) + | otherwise = (all_bndrs, []) +ppr_itv_bndrs [] _ = ([], []) pprIfaceForAllCo :: [(IfLclName, IfaceCoercion)] -> SDoc pprIfaceForAllCo [] = empty |