git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Small improvements to the pretty printer

- A do block had the first statement on the same line as the do block itself which caused later lines to not be indented properly. Instead, add a newline after the do so that all statements in the do block are indented properly. - The guards in a case expression were not indented at all, appearing on the very first character of the line. Instead, use withIndent and prettyPrintMany to properly indent each guard of a case expression.

commit0cabf010d2416fa92ecc978b4fa469664f11cdb8 authorJohn Lenz <lenz@math.uic.edu> dateTue 23 Jun 2015, 17:19 (11 years ago) parent39347bf
1 file changed+5−3
src/Language/PureScript/Pretty/Values.hs+5−3
src/Language/PureScript/Pretty/Values.hs+5−3
@@ -71,7 +71,7 @@ literals = mkPattern' match
7171 ]
7272 match (Var ident) = return $ show ident
7373 match (Do els) = concat <$> sequence
74− [ return "do "
74+ [ return "do\n"
7575 , withIndent $ prettyPrintMany prettyPrintDoNotationElement els
7676 , currentIndent
7777 ]
@@ -99,7 +99,10 @@ prettyPrintCaseAlternative (CaseAlternative binders result) =
9999 , prettyPrintResult result
100100 ]
101101 where
102− prettyPrintResult (Left gs) = concat <$> mapM prettyPrintGuardedValue gs
102+ prettyPrintResult (Left gs) = concat <$> sequence
103+ [ return "\n"
104+ , withIndent $ prettyPrintMany prettyPrintGuardedValue gs
105+ ]
103106 prettyPrintResult (Right v) = (" -> " ++) <$> prettyPrintValue' v
104107
105108 prettyPrintGuardedValue (grd, val) =
@@ -108,7 +111,6 @@ prettyPrintCaseAlternative (CaseAlternative binders result) =
108111 , prettyPrintValue' grd
109112 , return " -> "
110113 , prettyPrintValue' val
111− , return "\n"
112114 ]
113115
114116prettyPrintDoNotationElement :: DoNotationElement -> StateT PrinterState Maybe String