Remove duplication in 'let' expression layout.

pull/66/head
Evan Rutledge Borden 2017-11-25 20:24:41 -05:00 committed by Lennart Spitzner
parent ba3d9ad739
commit 35f33c131c
1 changed files with 46 additions and 54 deletions

View File

@ -567,65 +567,57 @@ layoutExpr lexpr@(L _ expr) = do
(docSetBaseY $ expDoc1) (docSetBaseY $ expDoc1)
] ]
] ]
Just bindDocs@(_:_) -> docAlt $ Just bindDocs@(_:_) -> docAltFilter
case indentPolicy of --either
IndentPolicyLeft -> -- let
--either -- a = b
-- let -- c = d
-- a = b -- in foo
-- c = d -- bar
-- in foo -- baz
-- bar --or
-- baz -- let
--or -- a = b
-- let -- c = d
-- a = b -- in
-- c = d -- fooooooooooooooooooo
-- in [ ( indentPolicy == IndentPolicyLeft
-- fooooooooooooooooooo , docLines
[ docLines [ docAddBaseY BrIndentRegular
[ docAddBaseY BrIndentRegular $ docPar
$ docPar (docLit $ Text.pack "let")
(docLit $ Text.pack "let") (docSetBaseAndIndent $ docLines $ return <$> bindDocs)
(docSetBaseAndIndent $ docLines $ return <$> bindDocs) , docSeq
, docSeq [ docLit $ Text.pack "in "
[ docLit $ Text.pack "in " , docAddBaseY BrIndentRegular $ expDoc1
, docAddBaseY BrIndentRegular $ expDoc1
]
]
, docLines
[ docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "in")
(docSetBaseY $ expDoc1)
] ]
] ]
_ -> )
[ docLines , ( indentPolicy /= IndentPolicyLeft
[ docSeq , docLines
[ appSep $ docLit $ Text.pack "let" [ docSeq
, docSetBaseAndIndent $ docLines $ return <$> bindDocs [ appSep $ docLit $ Text.pack "let"
] , docSetBaseAndIndent $ docLines $ return <$> bindDocs
, docSeq
[ appSep $ docLit $ Text.pack "in "
, docSetBaseY $ expDoc1
]
] ]
, docLines , docSeq
[ docAddBaseY BrIndentRegular [ appSep $ docLit $ Text.pack "in "
$ docPar , docSetBaseY $ expDoc1
(docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "in")
(docSetBaseY $ expDoc1)
] ]
] ]
)
, ( True
, docLines
[ docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "in")
(docSetBaseY $ expDoc1)
]
)
]
_ -> docSeq [appSep $ docLit $ Text.pack "let in", expDoc1] _ -> docSeq [appSep $ docLit $ Text.pack "let in", expDoc1]
-- docSeq [appSep $ docLit "let in", expDoc1] -- docSeq [appSep $ docLit "let in", expDoc1]
HsDo DoExpr (L _ stmts) _ -> do HsDo DoExpr (L _ stmts) _ -> do