diff --git a/src-literatetests/tests-context-free.blt b/src-literatetests/tests-context-free.blt index 5048175..5f5765a 100644 --- a/src-literatetests/tests-context-free.blt +++ b/src-literatetests/tests-context-free.blt @@ -532,8 +532,7 @@ func = do #test let func = do - let - x = 13 + let x = 13 stmt x @@ -1020,8 +1019,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do ] | not hasComments , [(guards, body, _bodyRaw)] <- [clauseDocs] - , let - guardPart = singleLineGuardsDoc guards + , let guardPart = singleLineGuardsDoc guards , wherePart <- case mWhereDocs of Nothing -> return @[] $ docEmpty Just [w] -> return @[] $ docSeq @@ -1042,8 +1040,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do ] ++ wherePartMultiLine | [(guards, body, _bodyRaw)] <- [clauseDocs] - , let - guardPart = singleLineGuardsDoc guards + , let guardPart = singleLineGuardsDoc guards , Data.Maybe.isJust mWhereDocs ] ++ -- two-line solution + where in next line(s) @@ -1055,8 +1052,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do ] ++ wherePartMultiLine | [(guards, body, _bodyRaw)] <- [clauseDocs] - , let - guardPart = singleLineGuardsDoc guards + , let guardPart = singleLineGuardsDoc guards ] #test comment-testcase-17 diff --git a/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs b/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs index d108ed1..4b96241 100644 --- a/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs +++ b/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs @@ -541,7 +541,7 @@ layoutExpr lexpr@(L _ expr) = do -- comments before the first let item are moved horizontally with it. docSetIndentLevel $ case mBindDocs of Just [bindDoc] -> docAltFilter - [ ( indentPolicy /= IndentPolicyLeft + [ ( True , docSeq [ appSep $ docLit $ Text.pack "let" , appSep $ docForceSingleline $ return bindDoc diff --git a/src/Language/Haskell/Brittany/Internal/Layouters/Stmt.hs b/src/Language/Haskell/Brittany/Internal/Layouters/Stmt.hs index c9494e3..b8814cd 100644 --- a/src/Language/Haskell/Brittany/Internal/Layouters/Stmt.hs +++ b/src/Language/Haskell/Brittany/Internal/Layouters/Stmt.hs @@ -54,22 +54,22 @@ layoutStmt lstmt@(L _ stmt) = do -- indeed allowed. -- heh. Just [] -> docLit $ Text.pack "let" -- this probably never happens - Just [bindDoc] -> docAltFilter + Just [bindDoc] -> docAlt [ -- let bind = expr - ( indentPolicy /= IndentPolicyLeft - , docCols - ColDoLet - [ appSep $ docLit $ Text.pack "let" - , docSetBaseAndIndent $ return bindDoc - ] - ) + docCols + ColDoLet + [ appSep $ docLit $ Text.pack "let" + , ( if indentPolicy == IndentPolicyLeft + then docForceSingleline + else docSetBaseAndIndent + ) + $ return bindDoc + ] , -- let -- bind = expr - ( True - , docAddBaseY BrIndentRegular $ docPar - (docLit $ Text.pack "let") - (docSetBaseAndIndent $ return bindDoc) - ) + docAddBaseY BrIndentRegular $ docPar + (docLit $ Text.pack "let") + (docSetBaseAndIndent $ return bindDoc) ] Just bindDocs -> docAltFilter [ -- let aaa = expra @@ -107,9 +107,8 @@ layoutStmt lstmt@(L _ stmt) = do -- stmt2 -- stmt3 ( True - , docAddBaseY BrIndentRegular $ docPar - (docLit (Text.pack "rec")) - (docLines $ layoutStmt <$> stmts) + , docAddBaseY BrIndentRegular + $ docPar (docLit (Text.pack "rec")) (docLines $ layoutStmt <$> stmts) ) ] BodyStmt expr _ _ _ -> do