on master help sign in
Align multi-line types in more cases
a639058Evan Czaplicki
compiler/src/Reporting/Doc.hs+1−1
@@ -3,7 +3,7 @@
3module Reporting.Doc
3module Reporting.Doc
4 ( P.Doc
4 ( P.Doc
5 , (P.<+>), (<>)
5 , (P.<+>), (<>)
6− , P.cat, P.empty, P.fill, P.fillSep, P.hang
6+ , P.align, P.cat, P.empty, P.fill, P.fillSep, P.hang
7 , P.hcat, P.hsep, P.indent, P.sep, P.vcat
7 , P.hcat, P.hsep, P.indent, P.sep, P.vcat
8 , P.red, P.magenta, P.green, P.blue, P.black
8 , P.red, P.magenta, P.green, P.blue, P.black
9 , P.dullred, P.dullcyan, P.dullyellow
9 , P.dullred, P.dullcyan, P.dullyellow
compiler/src/Reporting/Render/Type.hs+4−4
@@ -40,7 +40,7 @@ lambda :: Context -> Doc -> Doc -> [Doc] -> Doc
40lambda context arg1 arg2 args =
40lambda context arg1 arg2 args =
41 let
41 let
42 lambdaDoc =
42 lambdaDoc =
43− D.sep (arg1 : map ("->" <+>) (arg2:args))
43+ D.align $ D.sep (arg1 : map ("->" <+>) (arg2:args))
44 in
44 in
45 case context of
45 case context of
46 None -> lambdaDoc
46 None -> lambdaDoc
@@ -71,7 +71,7 @@ tuple a b cs =
71 entries =
71 entries =
72 zipWith (<+>) ("(" : repeat ",") (a:b:cs)
72 zipWith (<+>) ("(" : repeat ",") (a:b:cs)
73 in
73 in
74− D.sep [ D.cat entries, ")" ]
74+ D.align $ D.sep [ D.cat entries, ")" ]
75
75
76
76
77record :: [(Doc, Doc)] -> Maybe Doc -> Doc
77record :: [(Doc, Doc)] -> Maybe Doc -> Doc
@@ -81,13 +81,13 @@ record entries maybeExt =
81 "{}"
81 "{}"
82
82
83 (fields, Nothing) ->
83 (fields, Nothing) ->
84− D.sep
84+ D.align $ D.sep $
85 [ D.cat (zipWith (<+>) ("{" : repeat ",") fields)
85 [ D.cat (zipWith (<+>) ("{" : repeat ",") fields)
86 , "}"
86 , "}"
87 ]
87 ]
88
88
89 (fields, Just ext) ->
89 (fields, Just ext) ->
90− D.sep
90+ D.align $ D.sep $
91 [ D.hang 4 $ D.sep $
91 [ D.hang 4 $ D.sep $
92 [ "{" <+> ext
92 [ "{" <+> ext
93 , D.cat (zipWith (<+>) ("|" : repeat ",") fields)
93 , D.cat (zipWith (<+>) ("|" : repeat ",") fields)