Allow single-line after let with IndentPolicyLeft

pull/66/head
Lennart Spitzner 2017-11-27 23:27:33 +01:00
parent d9155e240d
commit 882a3b1a7a
3 changed files with 20 additions and 25 deletions

View File

@ -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

View File

@ -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

View File

@ -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
docCols
ColDoLet
[ appSep $ docLit $ Text.pack "let"
, docSetBaseAndIndent $ return bindDoc
]
, ( if indentPolicy == IndentPolicyLeft
then docForceSingleline
else docSetBaseAndIndent
)
$ return bindDoc
]
, -- let
-- bind = expr
( True
, docAddBaseY BrIndentRegular $ docPar
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