Restore aligning on non-function bindings
parent
371fad303d
commit
fc47372005
|
@ -84,7 +84,7 @@ layoutBind lbind@(L _ bind) = case bind of
|
||||||
clauseDocs <- layoutGrhs `mapM` grhss
|
clauseDocs <- layoutGrhs `mapM` grhss
|
||||||
mWhereDocs <- layoutLocalBinds whereBinds
|
mWhereDocs <- layoutLocalBinds whereBinds
|
||||||
binderDoc <- docLit $ Text.pack "="
|
binderDoc <- docLit $ Text.pack "="
|
||||||
fmap Right $ docWrapNode lbind $ layoutPatternBindFinal Text.empty binderDoc (Just patDoc) clauseDocs mWhereDocs
|
fmap Right $ docWrapNode lbind $ layoutPatternBindFinal Nothing binderDoc (Just patDoc) clauseDocs mWhereDocs
|
||||||
_ -> Right <$> unknownNodeError "" lbind
|
_ -> Right <$> unknownNodeError "" lbind
|
||||||
|
|
||||||
data BagBindOrSig = BagBind (LHsBindLR RdrName RdrName)
|
data BagBindOrSig = BagBind (LHsBindLR RdrName RdrName)
|
||||||
|
@ -144,10 +144,11 @@ layoutPatternBind mIdStr binderDoc lmatch@(L _ match@(Match _ pats _ (GRHSs grhs
|
||||||
$ (List.intersperse docSeparator $ docForceSingleline <$> ps)
|
$ (List.intersperse docSeparator $ docForceSingleline <$> ps)
|
||||||
clauseDocs <- docWrapNodeRest lmatch $ layoutGrhs `mapM` grhss
|
clauseDocs <- docWrapNodeRest lmatch $ layoutGrhs `mapM` grhss
|
||||||
mWhereDocs <- layoutLocalBinds whereBinds
|
mWhereDocs <- layoutLocalBinds whereBinds
|
||||||
layoutPatternBindFinal (fromMaybe Text.empty mIdStr) binderDoc (Just patDoc) clauseDocs mWhereDocs
|
let alignmentToken = if null pats then Nothing else mIdStr
|
||||||
|
layoutPatternBindFinal alignmentToken binderDoc (Just patDoc) clauseDocs mWhereDocs
|
||||||
|
|
||||||
layoutPatternBindFinal :: Text -> BriDocNumbered -> Maybe BriDocNumbered -> [([BriDocNumbered], BriDocNumbered, LHsExpr RdrName)] -> Maybe [BriDocNumbered] -> ToBriDocM BriDocNumbered
|
layoutPatternBindFinal :: Maybe Text -> BriDocNumbered -> Maybe BriDocNumbered -> [([BriDocNumbered], BriDocNumbered, LHsExpr RdrName)] -> Maybe [BriDocNumbered] -> ToBriDocM BriDocNumbered
|
||||||
layoutPatternBindFinal idStr binderDoc mPatDoc clauseDocs mWhereDocs = do
|
layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs mWhereDocs = do
|
||||||
let patPartInline = case mPatDoc of
|
let patPartInline = case mPatDoc of
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
Just patDoc -> [appSep $ docForceSingleline $ return patDoc]
|
Just patDoc -> [appSep $ docForceSingleline $ return patDoc]
|
||||||
|
@ -175,7 +176,7 @@ layoutPatternBindFinal idStr binderDoc mPatDoc clauseDocs mWhereDocs = do
|
||||||
]
|
]
|
||||||
docAlt $
|
docAlt $
|
||||||
-- one-line solution
|
-- one-line solution
|
||||||
[ docCols (ColBindingLine idStr)
|
[ docCols (ColBindingLine alignmentToken)
|
||||||
[ docSeq
|
[ docSeq
|
||||||
(patPartInline ++ [guardPart])
|
(patPartInline ++ [guardPart])
|
||||||
, docSeq
|
, docSeq
|
||||||
|
@ -203,7 +204,7 @@ layoutPatternBindFinal idStr binderDoc mPatDoc clauseDocs mWhereDocs = do
|
||||||
] ++
|
] ++
|
||||||
-- one-line solution + where in next line(s)
|
-- one-line solution + where in next line(s)
|
||||||
[ docLines
|
[ docLines
|
||||||
$ [ docCols (ColBindingLine idStr)
|
$ [ docCols (ColBindingLine alignmentToken)
|
||||||
[ docSeq
|
[ docSeq
|
||||||
(patPartInline ++ [guardPart])
|
(patPartInline ++ [guardPart])
|
||||||
, docSeq
|
, docSeq
|
||||||
|
@ -242,7 +243,7 @@ layoutPatternBindFinal idStr binderDoc mPatDoc clauseDocs mWhereDocs = do
|
||||||
-- pattern and exactly one clause in single line, body as par;
|
-- pattern and exactly one clause in single line, body as par;
|
||||||
-- where in following lines
|
-- where in following lines
|
||||||
[ docLines
|
[ docLines
|
||||||
$ [ docCols (ColBindingLine idStr)
|
$ [ docCols (ColBindingLine alignmentToken)
|
||||||
[ docSeq
|
[ docSeq
|
||||||
(patPartInline ++ [appSep guardPart])
|
(patPartInline ++ [appSep guardPart])
|
||||||
, docSeq
|
, docSeq
|
||||||
|
|
|
@ -392,7 +392,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
binderDoc <- docLit $ Text.pack " ->"
|
binderDoc <- docLit $ Text.pack " ->"
|
||||||
docAddBaseY BrIndentRegular $ docPar
|
docAddBaseY BrIndentRegular $ docPar
|
||||||
(docLit $ Text.pack "if")
|
(docLit $ Text.pack "if")
|
||||||
(layoutPatternBindFinal Text.empty binderDoc Nothing clauseDocs Nothing)
|
(layoutPatternBindFinal Nothing binderDoc Nothing clauseDocs Nothing)
|
||||||
HsLet binds exp1 -> do
|
HsLet binds exp1 -> do
|
||||||
expDoc1 <- docSharedWrapper layoutExpr exp1
|
expDoc1 <- docSharedWrapper layoutExpr exp1
|
||||||
mBindDocs <- layoutLocalBinds binds
|
mBindDocs <- layoutLocalBinds binds
|
||||||
|
|
|
@ -146,7 +146,7 @@ data ColSig
|
||||||
-- Has variable number of columns depending on the number of patterns.
|
-- Has variable number of columns depending on the number of patterns.
|
||||||
| ColPatterns
|
| ColPatterns
|
||||||
| ColCasePattern
|
| ColCasePattern
|
||||||
| ColBindingLine Text
|
| ColBindingLine (Maybe Text)
|
||||||
-- e.g. "func pat pat = expr"
|
-- e.g. "func pat pat = expr"
|
||||||
-- 1111111111111222222
|
-- 1111111111111222222
|
||||||
-- or "pat | stmt -> expr"
|
-- or "pat | stmt -> expr"
|
||||||
|
|
Loading…
Reference in New Issue