Change record update syntax for left indent policy

pull/66/head
Evan Rutledge Borden 2017-11-19 16:03:29 -05:00 committed by Lennart Spitzner
parent a6bea7542b
commit 44e95940c0
2 changed files with 85 additions and 78 deletions

View File

@ -646,7 +646,8 @@ func = do
#test record update indentation 2 #test record update indentation 2
func = do func = do
s <- mGet s <- mGet
mSet $ s { _lstate_indent = _lstate_indent state mSet $ s
{ _lstate_indent = _lstate_indent state
, _lstate_indent = _lstate_indent state , _lstate_indent = _lstate_indent state
} }
@ -972,8 +973,8 @@ runBrittany tabSize text = do
let let
config' = staticDefaultConfig config' = staticDefaultConfig
config = config' config = config'
{ _conf_layout = (_conf_layout config') { _lconfig_indentAmount = coerce { _conf_layout = (_conf_layout config')
tabSize { _lconfig_indentAmount = coerce tabSize
} }
, _conf_forward = forwardOptionsSyntaxExtsEnabled , _conf_forward = forwardOptionsSyntaxExtsEnabled
} }

View File

@ -853,9 +853,10 @@ layoutExpr lexpr@(L _ expr) = do
return $ case ambName of return $ case ambName of
Unambiguous n _ -> (lfield, lrdrNameToText n, rFExpDoc) Unambiguous n _ -> (lfield, lrdrNameToText n, rFExpDoc)
Ambiguous n _ -> (lfield, lrdrNameToText n, rFExpDoc) Ambiguous n _ -> (lfield, lrdrNameToText n, rFExpDoc)
docAlt docAltFilter
-- singleline -- singleline
[ docSeq [ ( True
, docSeq
[ docNodeAnnKW lexpr Nothing $ appSep $ docForceSingleline rExprDoc [ docNodeAnnKW lexpr Nothing $ appSep $ docForceSingleline rExprDoc
, appSep $ docLit $ Text.pack "{" , appSep $ docLit $ Text.pack "{"
, appSep $ docSeq $ List.intersperse docCommaSep , appSep $ docSeq $ List.intersperse docCommaSep
@ -870,7 +871,9 @@ layoutExpr lexpr@(L _ expr) = do
docWrapNode lfield $ docLit fieldStr docWrapNode lfield $ docLit fieldStr
, docLit $ Text.pack "}" , docLit $ Text.pack "}"
] ]
)
-- wild-indentation block -- wild-indentation block
, ( indentPolicy /= IndentPolicyLeft
, docSeq , docSeq
[ docNodeAnnKW lexpr Nothing $ appSep rExprDoc [ docNodeAnnKW lexpr Nothing $ appSep rExprDoc
, docSetBaseY $ docLines $ let , docSetBaseY $ docLines $ let
@ -899,7 +902,9 @@ layoutExpr lexpr@(L _ expr) = do
] ]
in [line1] ++ lineR ++ [lineN] in [line1] ++ lineR ++ [lineN]
] ]
)
-- strict indentation block -- strict indentation block
, ( True
, docSetParSpacing , docSetParSpacing
$ docAddBaseY BrIndentRegular $ docAddBaseY BrIndentRegular
$ docPar $ docPar
@ -928,6 +933,7 @@ layoutExpr lexpr@(L _ expr) = do
, docLit $ Text.pack "}" , docLit $ Text.pack "}"
] ]
in [line1] ++ lineR ++ [lineN]) in [line1] ++ lineR ++ [lineN])
)
] ]
#if MIN_VERSION_ghc(8,2,0) /* ghc-8.2 */ #if MIN_VERSION_ghc(8,2,0) /* ghc-8.2 */
ExprWithTySig exp1 (HsWC _ (HsIB _ typ1 _)) -> do ExprWithTySig exp1 (HsWC _ (HsIB _ typ1 _)) -> do
@ -959,7 +965,7 @@ layoutExpr lexpr@(L _ expr) = do
docSeq docSeq
[ docLit $ Text.pack "[" [ docLit $ Text.pack "["
, docForceSingleline e1Doc , docForceSingleline e1Doc
, docCommaSep , appSep $ docLit $ Text.pack ","
, appSep $ docForceSingleline e2Doc , appSep $ docForceSingleline e2Doc
, docLit $ Text.pack "..]" , docLit $ Text.pack "..]"
] ]
@ -980,7 +986,7 @@ layoutExpr lexpr@(L _ expr) = do
docSeq docSeq
[ docLit $ Text.pack "[" [ docLit $ Text.pack "["
, docForceSingleline e1Doc , docForceSingleline e1Doc
, docCommaSep , appSep $ docLit $ Text.pack ","
, appSep $ docForceSingleline e2Doc , appSep $ docForceSingleline e2Doc
, appSep $ docLit $ Text.pack ".." , appSep $ docLit $ Text.pack ".."
, docForceSingleline eNDoc , docForceSingleline eNDoc