Fix NonBottom/setBaseY getSpacing(s) interaction
- Rename NonBottom -> Alwayspull/3/head
parent
cc9b1f6885
commit
8277e85187
|
@ -456,7 +456,7 @@ transformAlts briDoc
|
||||||
hasSpace2 lconf (AltCurPos line indent indentPrep _) (VerticalSpacing sameLine (VerticalSpacingParSome par) _)
|
hasSpace2 lconf (AltCurPos line indent indentPrep _) (VerticalSpacing sameLine (VerticalSpacingParSome par) _)
|
||||||
= line + sameLine <= confUnpack (_lconfig_cols lconf)
|
= line + sameLine <= confUnpack (_lconfig_cols lconf)
|
||||||
&& indent + indentPrep + par <= confUnpack (_lconfig_cols lconf)
|
&& indent + indentPrep + par <= confUnpack (_lconfig_cols lconf)
|
||||||
hasSpace2 lconf (AltCurPos line _indent _ _) (VerticalSpacing sameLine VerticalSpacingParNonBottom _)
|
hasSpace2 lconf (AltCurPos line _indent _ _) (VerticalSpacing sameLine VerticalSpacingParAlways{} _)
|
||||||
= line + sameLine <= confUnpack (_lconfig_cols lconf)
|
= line + sameLine <= confUnpack (_lconfig_cols lconf)
|
||||||
|
|
||||||
getSpacing :: forall m . (MonadMultiReader Config m, MonadMultiWriter (Seq String) m) => BriDocNumbered -> m (LineModeValidity VerticalSpacing)
|
getSpacing :: forall m . (MonadMultiReader Config m, MonadMultiWriter (Seq String) m) => BriDocNumbered -> m (LineModeValidity VerticalSpacing)
|
||||||
|
@ -465,6 +465,7 @@ getSpacing !bridoc = rec bridoc
|
||||||
rec :: BriDocNumbered -> m (LineModeValidity VerticalSpacing)
|
rec :: BriDocNumbered -> m (LineModeValidity VerticalSpacing)
|
||||||
rec (brDcId, brDc) = do
|
rec (brDcId, brDc) = do
|
||||||
config <- mAsk
|
config <- mAsk
|
||||||
|
let colMax = config & _conf_layout & _lconfig_cols & confUnpack
|
||||||
result <- case brDc of
|
result <- case brDc of
|
||||||
-- BDWrapAnnKey _annKey bd -> rec bd
|
-- BDWrapAnnKey _annKey bd -> rec bd
|
||||||
BDFEmpty ->
|
BDFEmpty ->
|
||||||
|
@ -481,7 +482,14 @@ getSpacing !bridoc = rec bridoc
|
||||||
return $ mVs <&> \vs -> vs
|
return $ mVs <&> \vs -> vs
|
||||||
{ _vs_paragraph = case _vs_paragraph vs of
|
{ _vs_paragraph = case _vs_paragraph vs of
|
||||||
VerticalSpacingParNone -> VerticalSpacingParNone
|
VerticalSpacingParNone -> VerticalSpacingParNone
|
||||||
VerticalSpacingParNonBottom -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways i -> VerticalSpacingParAlways $ case indent of
|
||||||
|
BrIndentNone -> i
|
||||||
|
BrIndentRegular -> i + ( confUnpack
|
||||||
|
$ _lconfig_indentAmount
|
||||||
|
$ _conf_layout
|
||||||
|
$ config
|
||||||
|
)
|
||||||
|
BrIndentSpecial j -> i + j
|
||||||
VerticalSpacingParSome i -> VerticalSpacingParSome $ case indent of
|
VerticalSpacingParSome i -> VerticalSpacingParSome $ case indent of
|
||||||
BrIndentNone -> i
|
BrIndentNone -> i
|
||||||
BrIndentRegular -> i + ( confUnpack
|
BrIndentRegular -> i + ( confUnpack
|
||||||
|
@ -503,8 +511,8 @@ getSpacing !bridoc = rec bridoc
|
||||||
(case _vs_paragraph vs of
|
(case _vs_paragraph vs of
|
||||||
VerticalSpacingParNone -> 0
|
VerticalSpacingParNone -> 0
|
||||||
VerticalSpacingParSome i -> i
|
VerticalSpacingParSome i -> i
|
||||||
VerticalSpacingParNonBottom -> 999)
|
VerticalSpacingParAlways i -> min colMax i)
|
||||||
, _vs_paragraph = VerticalSpacingParNonBottom
|
, _vs_paragraph = VerticalSpacingParAlways 0
|
||||||
}
|
}
|
||||||
BDFBaseYPop bd -> rec bd
|
BDFBaseYPop bd -> rec bd
|
||||||
BDFIndentLevelPushCur bd -> rec bd
|
BDFIndentLevelPushCur bd -> rec bd
|
||||||
|
@ -520,7 +528,7 @@ getSpacing !bridoc = rec bridoc
|
||||||
, let pspResult = case mPsp of
|
, let pspResult = case mPsp of
|
||||||
VerticalSpacingParSome psp -> VerticalSpacingParSome $ max psp lineMax
|
VerticalSpacingParSome psp -> VerticalSpacingParSome $ max psp lineMax
|
||||||
VerticalSpacingParNone -> VerticalSpacingParSome $ lineMax
|
VerticalSpacingParNone -> VerticalSpacingParSome $ lineMax
|
||||||
VerticalSpacingParNonBottom -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways psp -> VerticalSpacingParAlways $ max psp lineMax
|
||||||
, let parFlagResult = mPsp == VerticalSpacingParNone
|
, let parFlagResult = mPsp == VerticalSpacingParNone
|
||||||
&& _vs_paragraph indSp == VerticalSpacingParNone
|
&& _vs_paragraph indSp == VerticalSpacingParNone
|
||||||
&& _vs_parFlag indSp
|
&& _vs_parFlag indSp
|
||||||
|
@ -566,7 +574,7 @@ getSpacing !bridoc = rec bridoc
|
||||||
return
|
return
|
||||||
$ mVs
|
$ mVs
|
||||||
<|> LineModeValid (VerticalSpacing 0
|
<|> LineModeValid (VerticalSpacing 0
|
||||||
VerticalSpacingParNonBottom
|
(VerticalSpacingParAlways colMax)
|
||||||
False)
|
False)
|
||||||
BDFSetParSpacing bd -> do
|
BDFSetParSpacing bd -> do
|
||||||
mVs <- rec bd
|
mVs <- rec bd
|
||||||
|
@ -589,9 +597,14 @@ getSpacing !bridoc = rec bridoc
|
||||||
VerticalSpacing (max x1 y1) (case (x2, y2) of
|
VerticalSpacing (max x1 y1) (case (x2, y2) of
|
||||||
(x, VerticalSpacingParNone) -> x
|
(x, VerticalSpacingParNone) -> x
|
||||||
(VerticalSpacingParNone, x) -> x
|
(VerticalSpacingParNone, x) -> x
|
||||||
(_, VerticalSpacingParNonBottom) -> VerticalSpacingParNonBottom
|
(VerticalSpacingParAlways i, VerticalSpacingParAlways j) ->
|
||||||
(VerticalSpacingParNonBottom, _) -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways $ max i j
|
||||||
(VerticalSpacingParSome x, VerticalSpacingParSome y) -> VerticalSpacingParSome $ max x y) False))
|
(VerticalSpacingParAlways i, VerticalSpacingParSome j) ->
|
||||||
|
VerticalSpacingParAlways $ max i j
|
||||||
|
(VerticalSpacingParSome j, VerticalSpacingParAlways i) ->
|
||||||
|
VerticalSpacingParAlways $ max i j
|
||||||
|
(VerticalSpacingParSome x, VerticalSpacingParSome y) ->
|
||||||
|
VerticalSpacingParSome $ max x y) False))
|
||||||
(LineModeValid $ VerticalSpacing 0 VerticalSpacingParNone False)
|
(LineModeValid $ VerticalSpacing 0 VerticalSpacingParNone False)
|
||||||
sumVs :: [LineModeValidity VerticalSpacing] -> LineModeValidity VerticalSpacing
|
sumVs :: [LineModeValidity VerticalSpacing] -> LineModeValidity VerticalSpacing
|
||||||
sumVs sps = foldl' (liftM2 go) initial sps
|
sumVs sps = foldl' (liftM2 go) initial sps
|
||||||
|
@ -601,9 +614,14 @@ getSpacing !bridoc = rec bridoc
|
||||||
(case (x2, y2) of
|
(case (x2, y2) of
|
||||||
(x, VerticalSpacingParNone) -> x
|
(x, VerticalSpacingParNone) -> x
|
||||||
(VerticalSpacingParNone, x) -> x
|
(VerticalSpacingParNone, x) -> x
|
||||||
(_, VerticalSpacingParNonBottom) -> VerticalSpacingParNonBottom
|
(VerticalSpacingParAlways i, VerticalSpacingParAlways j) ->
|
||||||
(VerticalSpacingParNonBottom, _) -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways $ i+j
|
||||||
(VerticalSpacingParSome x, VerticalSpacingParSome y) -> VerticalSpacingParSome $ x + y)
|
(VerticalSpacingParAlways i, VerticalSpacingParSome j) ->
|
||||||
|
VerticalSpacingParAlways $ i+j
|
||||||
|
(VerticalSpacingParSome i, VerticalSpacingParAlways j) ->
|
||||||
|
VerticalSpacingParAlways $ i+j
|
||||||
|
(VerticalSpacingParSome x, VerticalSpacingParSome y) ->
|
||||||
|
VerticalSpacingParSome $ x + y)
|
||||||
x3
|
x3
|
||||||
singleline (LineModeValid x) = _vs_paragraph x == VerticalSpacingParNone
|
singleline (LineModeValid x) = _vs_paragraph x == VerticalSpacingParNone
|
||||||
singleline _ = False
|
singleline _ = False
|
||||||
|
@ -617,7 +635,7 @@ getSpacing !bridoc = rec bridoc
|
||||||
getMaxVS = fmap $ \(VerticalSpacing x1 x2 _) -> x1 `max` case x2 of
|
getMaxVS = fmap $ \(VerticalSpacing x1 x2 _) -> x1 `max` case x2 of
|
||||||
VerticalSpacingParSome i -> i
|
VerticalSpacingParSome i -> i
|
||||||
VerticalSpacingParNone -> 0
|
VerticalSpacingParNone -> 0
|
||||||
VerticalSpacingParNonBottom -> 999
|
VerticalSpacingParAlways i -> i
|
||||||
|
|
||||||
getSpacings :: forall m . (MonadMultiReader Config m, MonadMultiWriter (Seq String) m)
|
getSpacings :: forall m . (MonadMultiReader Config m, MonadMultiWriter (Seq String) m)
|
||||||
=> Int -> BriDocNumbered -> Memo.MemoT Int [VerticalSpacing] m [VerticalSpacing]
|
=> Int -> BriDocNumbered -> Memo.MemoT Int [VerticalSpacing] m [VerticalSpacing]
|
||||||
|
@ -635,7 +653,7 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
lsp <= colMax && case psp of
|
lsp <= colMax && case psp of
|
||||||
VerticalSpacingParNone -> True
|
VerticalSpacingParNone -> True
|
||||||
VerticalSpacingParSome i -> i <= colMax
|
VerticalSpacingParSome i -> i <= colMax
|
||||||
VerticalSpacingParNonBottom -> True
|
VerticalSpacingParAlways{} -> True
|
||||||
let filterAndLimit :: [VerticalSpacing] -> [VerticalSpacing]
|
let filterAndLimit :: [VerticalSpacing] -> [VerticalSpacing]
|
||||||
filterAndLimit = take limit
|
filterAndLimit = take limit
|
||||||
. filter hasOkColCount
|
. filter hasOkColCount
|
||||||
|
@ -662,7 +680,14 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
return $ mVs <&> \vs -> vs
|
return $ mVs <&> \vs -> vs
|
||||||
{ _vs_paragraph = case _vs_paragraph vs of
|
{ _vs_paragraph = case _vs_paragraph vs of
|
||||||
VerticalSpacingParNone -> VerticalSpacingParNone
|
VerticalSpacingParNone -> VerticalSpacingParNone
|
||||||
VerticalSpacingParNonBottom -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways i -> VerticalSpacingParAlways $ case indent of
|
||||||
|
BrIndentNone -> i
|
||||||
|
BrIndentRegular -> i + ( confUnpack
|
||||||
|
$ _lconfig_indentAmount
|
||||||
|
$ _conf_layout
|
||||||
|
$ config
|
||||||
|
)
|
||||||
|
BrIndentSpecial j -> i + j
|
||||||
VerticalSpacingParSome i -> VerticalSpacingParSome $ case indent of
|
VerticalSpacingParSome i -> VerticalSpacingParSome $ case indent of
|
||||||
BrIndentNone -> i
|
BrIndentNone -> i
|
||||||
BrIndentRegular -> i + ( confUnpack
|
BrIndentRegular -> i + ( confUnpack
|
||||||
|
@ -684,10 +709,11 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
(case _vs_paragraph vs of
|
(case _vs_paragraph vs of
|
||||||
VerticalSpacingParNone -> 0
|
VerticalSpacingParNone -> 0
|
||||||
VerticalSpacingParSome i -> i
|
VerticalSpacingParSome i -> i
|
||||||
VerticalSpacingParNonBottom -> 999)
|
VerticalSpacingParAlways i -> min colMax i)
|
||||||
, _vs_paragraph = case _vs_paragraph vs of
|
, _vs_paragraph = case _vs_paragraph vs of
|
||||||
VerticalSpacingParNone -> VerticalSpacingParNone
|
VerticalSpacingParNone -> VerticalSpacingParNone
|
||||||
_ -> VerticalSpacingParNonBottom
|
VerticalSpacingParSome i -> VerticalSpacingParAlways i -- TODO: is this correct?
|
||||||
|
VerticalSpacingParAlways i -> VerticalSpacingParAlways i
|
||||||
}
|
}
|
||||||
BDFBaseYPop bd -> rec bd
|
BDFBaseYPop bd -> rec bd
|
||||||
BDFIndentLevelPushCur bd -> rec bd
|
BDFIndentLevelPushCur bd -> rec bd
|
||||||
|
@ -708,7 +734,8 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
VerticalSpacingParSome psp ->
|
VerticalSpacingParSome psp ->
|
||||||
VerticalSpacingParSome $ max psp $ getMaxVS indSp -- TODO
|
VerticalSpacingParSome $ max psp $ getMaxVS indSp -- TODO
|
||||||
VerticalSpacingParNone -> spMakePar indSp
|
VerticalSpacingParNone -> spMakePar indSp
|
||||||
VerticalSpacingParNonBottom -> VerticalSpacingParNonBottom)
|
VerticalSpacingParAlways psp ->
|
||||||
|
VerticalSpacingParAlways $ max psp $ getMaxVS indSp)
|
||||||
( mPsp == VerticalSpacingParNone
|
( mPsp == VerticalSpacingParNone
|
||||||
&& _vs_paragraph indSp == VerticalSpacingParNone
|
&& _vs_paragraph indSp == VerticalSpacingParNone
|
||||||
&& _vs_parFlag indSp
|
&& _vs_parFlag indSp
|
||||||
|
@ -773,8 +800,13 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
BDFNonBottomSpacing bd -> do
|
BDFNonBottomSpacing bd -> do
|
||||||
mVs <- rec bd
|
mVs <- rec bd
|
||||||
return $ if null mVs
|
return $ if null mVs
|
||||||
then [VerticalSpacing 0 VerticalSpacingParNonBottom False]
|
then [VerticalSpacing 0 (VerticalSpacingParAlways colMax) False]
|
||||||
else mVs <&> \vs -> vs { _vs_paragraph = VerticalSpacingParNonBottom}
|
else mVs <&> \vs -> vs
|
||||||
|
{ _vs_paragraph = case _vs_paragraph vs of
|
||||||
|
VerticalSpacingParNone -> VerticalSpacingParNone
|
||||||
|
VerticalSpacingParAlways i -> VerticalSpacingParAlways i
|
||||||
|
VerticalSpacingParSome i -> VerticalSpacingParAlways i
|
||||||
|
}
|
||||||
BDFSetParSpacing bd -> do
|
BDFSetParSpacing bd -> do
|
||||||
mVs <- rec bd
|
mVs <- rec bd
|
||||||
return $ mVs <&> \vs -> vs { _vs_parFlag = True }
|
return $ mVs <&> \vs -> vs { _vs_parFlag = True }
|
||||||
|
@ -805,9 +837,14 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
(case (x2, y2) of
|
(case (x2, y2) of
|
||||||
(x, VerticalSpacingParNone) -> x
|
(x, VerticalSpacingParNone) -> x
|
||||||
(VerticalSpacingParNone, x) -> x
|
(VerticalSpacingParNone, x) -> x
|
||||||
(_, VerticalSpacingParNonBottom) -> VerticalSpacingParNonBottom
|
(VerticalSpacingParAlways i, VerticalSpacingParAlways j) ->
|
||||||
(VerticalSpacingParNonBottom, _) -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways $ max i j
|
||||||
(VerticalSpacingParSome x, VerticalSpacingParSome y) -> VerticalSpacingParSome $ max x y)
|
(VerticalSpacingParAlways i, VerticalSpacingParSome j) ->
|
||||||
|
VerticalSpacingParAlways $ max i j
|
||||||
|
(VerticalSpacingParSome i, VerticalSpacingParAlways j) ->
|
||||||
|
VerticalSpacingParAlways $ max i j
|
||||||
|
(VerticalSpacingParSome x, VerticalSpacingParSome y) ->
|
||||||
|
VerticalSpacingParSome $ max x y)
|
||||||
False)
|
False)
|
||||||
(VerticalSpacing 0 VerticalSpacingParNone False)
|
(VerticalSpacing 0 VerticalSpacingParNone False)
|
||||||
sumVs :: [VerticalSpacing] -> VerticalSpacing
|
sumVs :: [VerticalSpacing] -> VerticalSpacing
|
||||||
|
@ -818,8 +855,12 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
(case (x2, y2) of
|
(case (x2, y2) of
|
||||||
(x, VerticalSpacingParNone) -> x
|
(x, VerticalSpacingParNone) -> x
|
||||||
(VerticalSpacingParNone, x) -> x
|
(VerticalSpacingParNone, x) -> x
|
||||||
(_, VerticalSpacingParNonBottom) -> VerticalSpacingParNonBottom
|
(VerticalSpacingParAlways i, VerticalSpacingParAlways j) ->
|
||||||
(VerticalSpacingParNonBottom, _) -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways $ i+j
|
||||||
|
(VerticalSpacingParAlways i, VerticalSpacingParSome j) ->
|
||||||
|
VerticalSpacingParAlways $ i+j
|
||||||
|
(VerticalSpacingParSome i, VerticalSpacingParAlways j) ->
|
||||||
|
VerticalSpacingParAlways $ i+j
|
||||||
(VerticalSpacingParSome x, VerticalSpacingParSome y) -> VerticalSpacingParSome $ x + y)
|
(VerticalSpacingParSome x, VerticalSpacingParSome y) -> VerticalSpacingParSome $ x + y)
|
||||||
x3
|
x3
|
||||||
singleline x = _vs_paragraph x == VerticalSpacingParNone
|
singleline x = _vs_paragraph x == VerticalSpacingParNone
|
||||||
|
@ -832,12 +873,12 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
getMaxVS (VerticalSpacing x1 x2 _) = x1 `max` case x2 of
|
getMaxVS (VerticalSpacing x1 x2 _) = x1 `max` case x2 of
|
||||||
VerticalSpacingParSome i -> i
|
VerticalSpacingParSome i -> i
|
||||||
VerticalSpacingParNone -> 0
|
VerticalSpacingParNone -> 0
|
||||||
VerticalSpacingParNonBottom -> 999
|
VerticalSpacingParAlways i -> i
|
||||||
spMakePar :: VerticalSpacing -> VerticalSpacingPar
|
spMakePar :: VerticalSpacing -> VerticalSpacingPar
|
||||||
spMakePar (VerticalSpacing x1 x2 _) = case x2 of
|
spMakePar (VerticalSpacing x1 x2 _) = case x2 of
|
||||||
VerticalSpacingParSome i -> VerticalSpacingParSome $ x1 `max` i
|
VerticalSpacingParSome i -> VerticalSpacingParSome $ x1 `max` i
|
||||||
VerticalSpacingParNone -> VerticalSpacingParSome $ x1
|
VerticalSpacingParNone -> VerticalSpacingParSome $ x1
|
||||||
VerticalSpacingParNonBottom -> VerticalSpacingParNonBottom
|
VerticalSpacingParAlways i -> VerticalSpacingParAlways $ x1 `max` i
|
||||||
|
|
||||||
|
|
||||||
-- note that this is not total, and cannot be with that exact signature.
|
-- note that this is not total, and cannot be with that exact signature.
|
||||||
|
|
|
@ -66,6 +66,7 @@ module Language.Haskell.Brittany.LayoutBasics
|
||||||
, docSetParSpacing
|
, docSetParSpacing
|
||||||
, docForceParSpacing
|
, docForceParSpacing
|
||||||
, docDebug
|
, docDebug
|
||||||
|
, docSetBaseAndIndent
|
||||||
, briDocByExact
|
, briDocByExact
|
||||||
, briDocByExactNoComment
|
, briDocByExactNoComment
|
||||||
, foldedAnnKeys
|
, foldedAnnKeys
|
||||||
|
@ -943,6 +944,9 @@ docSetIndentLevel bdm = do
|
||||||
n2 <- allocateNode $ BDFIndentLevelPop n1
|
n2 <- allocateNode $ BDFIndentLevelPop n1
|
||||||
return n2
|
return n2
|
||||||
|
|
||||||
|
docSetBaseAndIndent :: ToBriDocM BriDocNumbered -> ToBriDocM BriDocNumbered
|
||||||
|
docSetBaseAndIndent = docSetBaseY . docSetIndentLevel
|
||||||
|
|
||||||
docSeparator :: ToBriDocM BriDocNumbered
|
docSeparator :: ToBriDocM BriDocNumbered
|
||||||
docSeparator = allocateNode BDFSeparator
|
docSeparator = allocateNode BDFSeparator
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
funcPatDocs <- docWrapNode lmatches $ layoutPatternBind Nothing binderDoc `mapM` matches
|
funcPatDocs <- docWrapNode lmatches $ layoutPatternBind Nothing binderDoc `mapM` matches
|
||||||
docSetParSpacing $ docAddBaseY BrIndentRegular $ docPar
|
docSetParSpacing $ docAddBaseY BrIndentRegular $ docPar
|
||||||
(docLit $ Text.pack "\\case")
|
(docLit $ Text.pack "\\case")
|
||||||
(docSetIndentLevel $ docNonBottomSpacing $ docLines $ return <$> funcPatDocs)
|
(docSetBaseAndIndent $ docNonBottomSpacing $ docLines $ return <$> funcPatDocs)
|
||||||
HsApp exp1@(L _ HsApp{}) exp2 -> do
|
HsApp exp1@(L _ HsApp{}) exp2 -> do
|
||||||
let gather :: [LHsExpr RdrName] -> LHsExpr RdrName -> (LHsExpr RdrName, [LHsExpr RdrName])
|
let gather :: [LHsExpr RdrName] -> LHsExpr RdrName -> (LHsExpr RdrName, [LHsExpr RdrName])
|
||||||
gather list = \case
|
gather list = \case
|
||||||
|
@ -282,14 +282,14 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
, appSep $ docForceSingleline cExpDoc
|
, appSep $ docForceSingleline cExpDoc
|
||||||
, docLit $ Text.pack "of"
|
, docLit $ Text.pack "of"
|
||||||
])
|
])
|
||||||
(docSetIndentLevel $ docNonBottomSpacing $ docLines $ return <$> funcPatDocs)
|
(docSetBaseAndIndent $ docNonBottomSpacing $ docLines $ return <$> funcPatDocs)
|
||||||
, docPar
|
, docPar
|
||||||
( docAddBaseY BrIndentRegular
|
( docAddBaseY BrIndentRegular
|
||||||
$ docPar (docLit $ Text.pack "case") cExpDoc
|
$ docPar (docLit $ Text.pack "case") cExpDoc
|
||||||
)
|
)
|
||||||
( docAddBaseY BrIndentRegular
|
( docAddBaseY BrIndentRegular
|
||||||
$ docPar (docLit $ Text.pack "of")
|
$ docPar (docLit $ Text.pack "of")
|
||||||
(docSetIndentLevel $ docNonBottomSpacing $ docLines $ return <$> funcPatDocs)
|
(docSetBaseAndIndent $ docNonBottomSpacing $ docLines $ return <$> funcPatDocs)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
HsIf _ ifExpr thenExpr elseExpr -> do
|
HsIf _ ifExpr thenExpr elseExpr -> do
|
||||||
|
@ -394,7 +394,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
, docLines
|
, docLines
|
||||||
[ docSeq
|
[ docSeq
|
||||||
[ appSep $ docLit $ Text.pack "let"
|
[ appSep $ docLit $ Text.pack "let"
|
||||||
, docSetIndentLevel $ return bindDoc
|
, docSetBaseAndIndent $ return bindDoc
|
||||||
]
|
]
|
||||||
, docSeq
|
, docSeq
|
||||||
[ appSep $ docLit $ Text.pack "in "
|
[ appSep $ docLit $ Text.pack "in "
|
||||||
|
@ -405,7 +405,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
[ docAddBaseY BrIndentRegular
|
[ docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(appSep $ docLit $ Text.pack "let")
|
(appSep $ docLit $ Text.pack "let")
|
||||||
(docSetIndentLevel $ return bindDoc)
|
(docSetBaseAndIndent $ return bindDoc)
|
||||||
, docAddBaseY BrIndentRegular
|
, docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(appSep $ docLit $ Text.pack "in")
|
(appSep $ docLit $ Text.pack "in")
|
||||||
|
@ -416,7 +416,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
[ docLines
|
[ docLines
|
||||||
[ docSeq
|
[ docSeq
|
||||||
[ appSep $ docLit $ Text.pack "let"
|
[ appSep $ docLit $ Text.pack "let"
|
||||||
, docSetIndentLevel $ docLines $ return <$> bindDocs
|
, docSetBaseAndIndent $ docLines $ return <$> bindDocs
|
||||||
]
|
]
|
||||||
, docSeq
|
, docSeq
|
||||||
[ appSep $ docLit $ Text.pack "in "
|
[ appSep $ docLit $ Text.pack "in "
|
||||||
|
@ -427,7 +427,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
[ docAddBaseY BrIndentRegular
|
[ docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "let")
|
(docLit $ Text.pack "let")
|
||||||
(docSetIndentLevel $ docLines $ return <$> bindDocs)
|
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
|
||||||
, docAddBaseY BrIndentRegular
|
, docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "in")
|
(docLit $ Text.pack "in")
|
||||||
|
@ -442,7 +442,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
$ docAddBaseY BrIndentRegular
|
$ docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "do")
|
(docLit $ Text.pack "do")
|
||||||
(docSetIndentLevel $ docNonBottomSpacing $ docLines stmtDocs)
|
(docSetBaseAndIndent $ docNonBottomSpacing $ docLines stmtDocs)
|
||||||
HsDo x (L _ stmts) _ | case x of { ListComp -> True
|
HsDo x (L _ stmts) _ | case x of { ListComp -> True
|
||||||
; MonadComp -> True
|
; MonadComp -> True
|
||||||
; _ -> False } -> do
|
; _ -> False } -> do
|
||||||
|
|
|
@ -56,21 +56,21 @@ layoutStmt lstmt@(L _ stmt) = docWrapNode lstmt $ case stmt of
|
||||||
Just [bindDoc] -> docAlt
|
Just [bindDoc] -> docAlt
|
||||||
[ docCols ColDoLet
|
[ docCols ColDoLet
|
||||||
[ appSep $ docLit $ Text.pack "let"
|
[ appSep $ docLit $ Text.pack "let"
|
||||||
, docSetIndentLevel $ return bindDoc
|
, docSetBaseAndIndent $ return bindDoc
|
||||||
]
|
]
|
||||||
, docAddBaseY BrIndentRegular $ docPar
|
, docAddBaseY BrIndentRegular $ docPar
|
||||||
(docLit $ Text.pack "let")
|
(docLit $ Text.pack "let")
|
||||||
(docSetIndentLevel $ return bindDoc)
|
(docSetBaseAndIndent $ return bindDoc)
|
||||||
]
|
]
|
||||||
Just bindDocs -> docAlt
|
Just bindDocs -> docAlt
|
||||||
[ docSeq
|
[ docSeq
|
||||||
[ appSep $ docLit $ Text.pack "let"
|
[ appSep $ docLit $ Text.pack "let"
|
||||||
, docSetIndentLevel $ docLines $ return <$> bindDocs
|
, docSetBaseAndIndent $ docLines $ return <$> bindDocs
|
||||||
]
|
]
|
||||||
, docAddBaseY BrIndentRegular
|
, docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "let")
|
(docLit $ Text.pack "let")
|
||||||
(docSetIndentLevel $ docLines $ return <$> bindDocs)
|
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
|
||||||
]
|
]
|
||||||
BodyStmt expr _ _ _ -> do
|
BodyStmt expr _ _ _ -> do
|
||||||
expDoc <- docSharedWrapper layoutExpr expr
|
expDoc <- docSharedWrapper layoutExpr expr
|
||||||
|
|
|
@ -385,12 +385,15 @@ briDocForceSpine bd = briDocSeqSpine bd `seq` bd
|
||||||
|
|
||||||
data VerticalSpacingPar
|
data VerticalSpacingPar
|
||||||
= VerticalSpacingParNone -- no indented lines
|
= VerticalSpacingParNone -- no indented lines
|
||||||
| VerticalSpacingParSome Int -- indented lines, requiring this much vertical
|
| VerticalSpacingParSome Int -- indented lines, requiring this much
|
||||||
-- space at most
|
-- vertical space at most
|
||||||
| VerticalSpacingParNonBottom -- indented lines, with an unknown amount of
|
| VerticalSpacingParAlways Int -- indented lines, requiring this much
|
||||||
-- space required. parents should consider this
|
-- vertical space at most, but should
|
||||||
-- as a valid option, but provide as much space
|
-- be considered as having space for
|
||||||
-- as possible.
|
-- any spacing validity check.
|
||||||
|
-- TODO: it might be wrong not to extend "always" to the none case, i.e.
|
||||||
|
-- we might get better properties of spacing operators by having a
|
||||||
|
-- product like (Normal|Always, None|Some Int).
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data VerticalSpacing
|
data VerticalSpacing
|
||||||
|
|
Loading…
Reference in New Issue