diff --git a/data/10-structured/expression-list.blt b/data/10-structured/expression-list.blt index ad8c8f2..8565228 100644 --- a/data/10-structured/expression-list.blt +++ b/data/10-structured/expression-list.blt @@ -21,3 +21,10 @@ foo = , 4 , 5 ] + +#test set-base-y for multiple line elements +foo = + [ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + , bbbbbbbbbbbbbbbbbb + $ cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc + ] diff --git a/data/15-regressions.blt b/data/15-regressions.blt index 5f1cbd3..234c1d7 100644 --- a/data/15-regressions.blt +++ b/data/15-regressions.blt @@ -215,13 +215,13 @@ showPackageDetailedInfo pkginfo = (altText null "[ Not available from server ]") (dispTopVersions 9 (preferredVersions pkginfo)) , entry - "Versions installed" - installedVersions - (altText - null - (if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]") - ) - (dispTopVersions 4 (preferredVersions pkginfo)) + "Versions installed" + installedVersions + (altText + null + (if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]") + ) + (dispTopVersions 4 (preferredVersions pkginfo)) , entry "Homepage" homepage orNotSpecified text , entry "Bug reports" bugReports orNotSpecified text , entry "Description" description hideIfNull reflowParagraphs @@ -236,10 +236,10 @@ showPackageDetailedInfo pkginfo = , entry "Documentation" haddockHtml showIfInstalled text , entry "Cached" haveTarball alwaysShow dispYesNo , if not (hasLib pkginfo) - then empty - else - text "Modules:" - $+$ nest 4 (vcat (map disp . sort . modules $ pkginfo)) + then empty + else + text "Modules:" + $+$ nest 4 (vcat (map disp . sort . modules $ pkginfo)) ] #test issue 7a @@ -413,10 +413,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do (ColBindingLine alignmentToken) [ docSeq (patPartInline ++ [guardPart]) , docSeq - [ appSep $ return binderDoc - , docForceSingleline $ return body - , wherePart - ] + [ appSep $ return binderDoc + , docForceSingleline $ return body + , wherePart + ] ] | not hasComments , [(guards, body, _bodyRaw)] <- [clauseDocs] @@ -436,7 +436,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do (ColBindingLine alignmentToken) [ docSeq (patPartInline ++ [guardPart]) , docSeq - [appSep $ return binderDoc, docForceParSpacing $ return body] + [appSep $ return binderDoc, docForceParSpacing $ return body] ] ] ++ wherePartMultiLine @@ -447,10 +447,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do ++ -- two-line solution + where in next line(s) [ docLines $ [ docForceSingleline $ docSeq - (patPartInline ++ [guardPart, return binderDoc]) + (patPartInline ++ [guardPart, return binderDoc]) , docEnsureIndent BrIndentRegular - $ docForceSingleline - $ return body + $ docForceSingleline + $ return body ] ++ wherePartMultiLine | [(guards, body, _bodyRaw)] <- [clauseDocs] diff --git a/data/30-tests-context-free.blt b/data/30-tests-context-free.blt index f361219..d0768d0 100644 --- a/data/30-tests-context-free.blt +++ b/data/30-tests-context-free.blt @@ -1149,18 +1149,18 @@ showPackageDetailedInfo pkginfo = $+$ something [ entry "Synopsis" synopsis hideIfNull reflowParagraphs , entry - "Versions available" - sourceVersions - (altText null "[ Not available from server ]") - (dispTopVersions 9 (preferredVersions pkginfo)) + "Versions available" + sourceVersions + (altText null "[ Not available from server ]") + (dispTopVersions 9 (preferredVersions pkginfo)) , entry - "Versions installed" - installedVersions - (altText - null - (if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]") - ) - (dispTopVersions 4 (preferredVersions pkginfo)) + "Versions installed" + installedVersions + (altText + null + (if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]") + ) + (dispTopVersions 4 (preferredVersions pkginfo)) , entry "Homepage" homepage orNotSpecified text , entry "Bug reports" bugReports orNotSpecified text , entry "Description" description hideIfNull reflowParagraphs @@ -1175,10 +1175,10 @@ showPackageDetailedInfo pkginfo = , entry "Documentation" haddockHtml showIfInstalled text , entry "Cached" haveTarball alwaysShow dispYesNo , if not (hasLib pkginfo) - then empty - else - text "Modules:" - $+$ nest 4 (vcat (map disp . sort . modules $ pkginfo)) + then empty + else + text "Modules:" + $+$ nest 4 (vcat (map disp . sort . modules $ pkginfo)) ] #test issue 7a @@ -1339,10 +1339,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do (ColBindingLine alignmentToken) [ docSeq (patPartInline ++ [guardPart]) , docSeq - [ appSep $ return binderDoc - , docForceSingleline $ return body - , wherePart - ] + [ appSep $ return binderDoc + , docForceSingleline $ return body + , wherePart + ] ] | not hasComments , [(guards, body, _bodyRaw)] <- [clauseDocs] @@ -1362,7 +1362,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do (ColBindingLine alignmentToken) [ docSeq (patPartInline ++ [guardPart]) , docSeq - [appSep $ return binderDoc, docForceParSpacing $ return body] + [appSep $ return binderDoc, docForceParSpacing $ return body] ] ] ++ wherePartMultiLine @@ -1373,10 +1373,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do ++ -- two-line solution + where in next line(s) [ docLines $ [ docForceSingleline $ docSeq - (patPartInline ++ [guardPart, return binderDoc]) + (patPartInline ++ [guardPart, return binderDoc]) , docEnsureIndent BrIndentRegular - $ docForceSingleline - $ return body + $ docForceSingleline + $ return body ] ++ wherePartMultiLine | [(guards, body, _bodyRaw)] <- [clauseDocs] diff --git a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs index a21a851..4da097b 100644 --- a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs +++ b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs @@ -736,15 +736,15 @@ layoutExpr lexpr@(L _ expr) = do , docForceSingleline eN , closeDoc] addAlternative - $ let start = docCols ColList [appSep $ openDoc, e1] + $ let start = docCols ColList [appSep $ openDoc, docSetBaseY e1] linesM = ems <&> \(p, ast, d) -> docCols ColList [ docHandleComms p docCommaSep - , docFlushCommsPost True ast $ d + , docSetBaseY $ docFlushCommsPost True ast $ d ] lineN = docCols ColList - [docHandleComms finalCommaPos $ docCommaSep, eN] + [docHandleComms finalCommaPos $ docCommaSep, docSetBaseY eN] in docSetBaseY $ docLines $ [start]