on master help sign in
Align multi-line types in more cases

So records, tuples, and functions will always be aligned with the opening { or ( when they break to multiple lines.

commita6390583a2329256f66902bb5e3bcc881038e862 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 24 Apr 2018, 13:52 (9 years ago) parente3f8972
2 files changed+5−5
compiler/src/Reporting/Doc.hs+1−1 compiler/src/Reporting/Render/Type.hs+4−4
compiler/src/Reporting/Doc.hs+1−1
@@ -3,7 +3,7 @@
33module Reporting.Doc
44 ( P.Doc
55 , (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
77 , P.hcat, P.hsep, P.indent, P.sep, P.vcat
88 , P.red, P.magenta, P.green, P.blue, P.black
99 , P.dullred, P.dullcyan, P.dullyellow
compiler/src/Reporting/Render/Type.hs+4−4
@@ -40,7 +40,7 @@ lambda :: Context -> Doc -> Doc -> [Doc] -> Doc
4040lambda context arg1 arg2 args =
4141 let
4242 lambdaDoc =
43− D.sep (arg1 : map ("->" <+>) (arg2:args))
43+ D.align $ D.sep (arg1 : map ("->" <+>) (arg2:args))
4444 in
4545 case context of
4646 None -> lambdaDoc
@@ -71,7 +71,7 @@ tuple a b cs =
7171 entries =
7272 zipWith (<+>) ("(" : repeat ",") (a:b:cs)
7373 in
74− D.sep [ D.cat entries, ")" ]
74+ D.align $ D.sep [ D.cat entries, ")" ]
7575
7676
7777record :: [(Doc, Doc)] -> Maybe Doc -> Doc
@@ -81,13 +81,13 @@ record entries maybeExt =
8181 "{}"
8282
8383 (fields, Nothing) ->
84− D.sep
84+ D.align $ D.sep $
8585 [ D.cat (zipWith (<+>) ("{" : repeat ",") fields)
8686 , "}"
8787 ]
8888
8989 (fields, Just ext) ->
90− D.sep
90+ D.align $ D.sep $
9191 [ D.hang 4 $ D.sep $
9292 [ "{" <+> ext
9393 , D.cat (zipWith (<+>) ("|" : repeat ",") fields)