Filter binders with docSetBaseAndIndent.

pull/66/head
Evan Rutledge Borden 2017-11-25 20:50:17 -05:00 committed by Lennart Spitzner
parent de0851f975
commit e9a2de7a85
3 changed files with 63 additions and 48 deletions

View File

@ -532,7 +532,8 @@ func = do
#test let #test let
func = do func = do
let x = 13 let
x = 13
stmt x stmt x
@ -1021,7 +1022,8 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
] ]
| not hasComments | not hasComments
, [(guards, body, _bodyRaw)] <- [clauseDocs] , [(guards, body, _bodyRaw)] <- [clauseDocs]
, let guardPart = singleLineGuardsDoc guards , let
guardPart = singleLineGuardsDoc guards
, wherePart <- case mWhereDocs of , wherePart <- case mWhereDocs of
Nothing -> return @[] $ docEmpty Nothing -> return @[] $ docEmpty
Just [w] -> return @[] $ docSeq Just [w] -> return @[] $ docSeq
@ -1042,7 +1044,8 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
] ]
++ wherePartMultiLine ++ wherePartMultiLine
| [(guards, body, _bodyRaw)] <- [clauseDocs] | [(guards, body, _bodyRaw)] <- [clauseDocs]
, let guardPart = singleLineGuardsDoc guards , let
guardPart = singleLineGuardsDoc guards
, Data.Maybe.isJust mWhereDocs , Data.Maybe.isJust mWhereDocs
] ]
++ -- two-line solution + where in next line(s) ++ -- two-line solution + where in next line(s)
@ -1054,13 +1057,15 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
] ]
++ wherePartMultiLine ++ wherePartMultiLine
| [(guards, body, _bodyRaw)] <- [clauseDocs] | [(guards, body, _bodyRaw)] <- [clauseDocs]
, let guardPart = singleLineGuardsDoc guards , let
guardPart = singleLineGuardsDoc guards
] ]
#test comment-testcase-17 #test comment-testcase-17
{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE MultiWayIf #-}
func = do func = do
let foo = if let
foo = if
| Constuctoooooooooooooooooooooooooooooooooooor `elem` artics -- TODO | Constuctoooooooooooooooooooooooooooooooooooor `elem` artics -- TODO
-> max -> max
(defLen - 0.2) -- TODO (defLen - 0.2) -- TODO

View File

@ -539,13 +539,16 @@ layoutExpr lexpr@(L _ expr) = do
-- if "let" is moved horizontally as part of the transformation, as the -- if "let" is moved horizontally as part of the transformation, as the
-- comments before the first let item are moved horizontally with it. -- comments before the first let item are moved horizontally with it.
docSetIndentLevel $ case mBindDocs of docSetIndentLevel $ case mBindDocs of
Just [bindDoc] -> docAlt Just [bindDoc] -> docAltFilter
[ docSeq [ ( indentPolicy /= IndentPolicyLeft
, docSeq
[ appSep $ docLit $ Text.pack "let" [ appSep $ docLit $ Text.pack "let"
, appSep $ docForceSingleline $ return bindDoc , appSep $ docForceSingleline $ return bindDoc
, appSep $ docLit $ Text.pack "in" , appSep $ docLit $ Text.pack "in"
, docForceSingleline $ expDoc1 , docForceSingleline $ expDoc1
] ]
)
, ( indentPolicy /= IndentPolicyLeft
, docLines , docLines
[ docSeq [ docSeq
[ appSep $ docLit $ Text.pack "let" [ appSep $ docLit $ Text.pack "let"
@ -556,6 +559,8 @@ layoutExpr lexpr@(L _ expr) = do
, docSetBaseY $ expDoc1 , docSetBaseY $ expDoc1
] ]
] ]
)
, ( True
, docLines , docLines
[ docAddBaseY BrIndentRegular [ docAddBaseY BrIndentRegular
$ docPar $ docPar
@ -566,6 +571,7 @@ layoutExpr lexpr@(L _ expr) = do
(appSep $ docLit $ Text.pack "in") (appSep $ docLit $ Text.pack "in")
(docSetBaseY $ expDoc1) (docSetBaseY $ expDoc1)
] ]
)
] ]
Just bindDocs@(_:_) -> docAltFilter Just bindDocs@(_:_) -> docAltFilter
--either --either

View File

@ -54,15 +54,19 @@ layoutStmt lstmt@(L _ stmt) = do
-- indeed allowed. -- indeed allowed.
-- heh. -- heh.
Just [] -> docLit $ Text.pack "let" -- this probably never happens Just [] -> docLit $ Text.pack "let" -- this probably never happens
Just [bindDoc] -> docAlt Just [bindDoc] -> docAltFilter
[ docCols [ ( indentPolicy /= IndentPolicyLeft
, docCols
ColDoLet ColDoLet
[ appSep $ docLit $ Text.pack "let" [ appSep $ docLit $ Text.pack "let"
, docSetBaseAndIndent $ return bindDoc , docSetBaseAndIndent $ return bindDoc
] ]
)
, ( True
, docAddBaseY BrIndentRegular $ docPar , docAddBaseY BrIndentRegular $ docPar
(docLit $ Text.pack "let") (docLit $ Text.pack "let")
(docSetBaseAndIndent $ return bindDoc) (docSetBaseAndIndent $ return bindDoc)
)
] ]
Just bindDocs -> docAltFilter Just bindDocs -> docAltFilter
[ ( indentPolicy /= IndentPolicyLeft [ ( indentPolicy /= IndentPolicyLeft