Compare commits
3 Commits
cf426f2040
...
e6956e9264
Author | SHA1 | Date |
---|---|---|
|
e6956e9264 | |
|
a8119e872c | |
|
7485938bf3 |
|
@ -1015,3 +1015,39 @@ catchFunc = do
|
||||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
)
|
)
|
||||||
`catch` catcher
|
`catch` catcher
|
||||||
|
|
||||||
|
#test comment after lambdacase
|
||||||
|
func = \case
|
||||||
|
-- zzz
|
||||||
|
False -> 0
|
||||||
|
True -> 1
|
||||||
|
|
||||||
|
#test comment for recordfield
|
||||||
|
func = myRecord { field = -- comment
|
||||||
|
if some condition then option one else option two
|
||||||
|
, otherfield = "text"
|
||||||
|
}
|
||||||
|
|
||||||
|
#test multiline guards within parenthesis
|
||||||
|
duGswidunBlxaq drux = DeeX.Vufcqqafi
|
||||||
|
(tiErihambSunxo drux)
|
||||||
|
(if
|
||||||
|
| geIqzscmBhiwo drux
|
||||||
|
-> Bmuh "Hpiioqa a yabufx ynyuq"
|
||||||
|
| liWaov drux
|
||||||
|
-> Bmuh "Ookhup ubqocf merr ukm ynyuq iitiop"
|
||||||
|
| tiErihambSunxo drux && bdp (alJukIkuh drux)
|
||||||
|
-> Bmuh "Jpgic dfaz dieb fs wreup hsv of ynyuq dio njr subdet"
|
||||||
|
| ukFinwuicUgIcclcep drux
|
||||||
|
-> Bmuh "Egwiqae-ka-molenqe codns dif'y ns csjyhth sisoyy"
|
||||||
|
| otherwise
|
||||||
|
-> Likiotq
|
||||||
|
)
|
||||||
|
|
||||||
|
#test multiline-block-comment in do-block
|
||||||
|
func = do
|
||||||
|
abc
|
||||||
|
{- some long
|
||||||
|
block comment -}
|
||||||
|
x <- readLine
|
||||||
|
print x
|
||||||
|
|
|
@ -641,29 +641,36 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauses (wrapBinds, mWhe
|
||||||
$ docLines
|
$ docLines
|
||||||
$ map docSetBaseY
|
$ map docSetBaseY
|
||||||
$ clauseDocs
|
$ clauseDocs
|
||||||
>>= \(grhsEpAnn, guardDocs, bodyDoc) -> -- TODO92
|
>>= \(grhsEpAnn, guardDocs, bodyDoc) -> case guardDocs of
|
||||||
(case guardDocs of
|
[] ->
|
||||||
[] -> [docHandleComms grhsEpAnn docEmpty]
|
[ docHandleComms grhsEpAnn
|
||||||
[g] ->
|
$ docCols
|
||||||
[ docHandleComms grhsEpAnn
|
ColOpPrefix
|
||||||
$ docSeq [appSep
|
[ appSep $ return binderDoc
|
||||||
$ docLit $ Text.pack "|", return g]
|
, docAddBaseY BrIndentRegular $ return bodyDoc
|
||||||
]
|
]
|
||||||
(g1 : gr) ->
|
]
|
||||||
( ( docHandleComms grhsEpAnn
|
[g] ->
|
||||||
$ docSeq [appSep $ docLit $ Text.pack "|", return g1]
|
[ docHandleComms grhsEpAnn
|
||||||
)
|
$ docSeq [appSep $ docLit $ Text.pack "|", return g]
|
||||||
: (gr <&> \g ->
|
, docSeq
|
||||||
docSeq [appSep $ docLit $ Text.pack ",", return g]
|
[ appSep $ return binderDoc
|
||||||
)
|
, docAddBaseY BrIndentRegular $ return bodyDoc
|
||||||
)
|
]
|
||||||
)
|
]
|
||||||
++ [ docCols
|
(g1 : gr) ->
|
||||||
ColOpPrefix
|
( [ docHandleComms grhsEpAnn
|
||||||
[ appSep $ return binderDoc
|
$ docSeq [appSep $ docLit $ Text.pack "|", return g1]
|
||||||
, docAddBaseY BrIndentRegular $ return bodyDoc
|
]
|
||||||
]
|
++ (gr <&> \g ->
|
||||||
]
|
docSeq [appSep $ docLit $ Text.pack ",", return g]
|
||||||
|
)
|
||||||
|
++ [ docSeq
|
||||||
|
[ appSep $ return binderDoc
|
||||||
|
, docAddBaseY BrIndentRegular $ return bodyDoc
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
++ wherePartMultiLine
|
++ wherePartMultiLine
|
||||||
|
|
||||||
|
|
|
@ -124,19 +124,22 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
docSetParSpacing
|
docSetParSpacing
|
||||||
$ docAddBaseY BrIndentRegular
|
$ docAddBaseY BrIndentRegular
|
||||||
$ (docLit $ Text.pack "\\case {}")
|
$ (docLit $ Text.pack "\\case {}")
|
||||||
HsLamCase _ (MG _ lmatches@(L _ matches) _) -> do
|
HsLamCase epAnn (MG _ lmatches@(L _ matches) _) -> do
|
||||||
binderDoc <- docLit $ Text.pack "->"
|
binderDoc <- docLit $ Text.pack "->"
|
||||||
layouters <- mAsk
|
layouters <- mAsk
|
||||||
funcPatDocs <-
|
funcPatDocs <-
|
||||||
layout_patternBind layouters Nothing binderDoc `mapM` matches
|
layout_patternBind layouters Nothing binderDoc `mapM` matches
|
||||||
docSetParSpacing $ docAddBaseY BrIndentRegular $ docPar
|
docSetParSpacing
|
||||||
(docLit $ Text.pack "\\case")
|
$ docAddBaseY BrIndentRegular
|
||||||
( docSetBaseAndIndent
|
$ docHandleComms epAnn
|
||||||
$ docNonBottomSpacing
|
$ docPar
|
||||||
$ docHandleComms lmatches
|
(docLit $ Text.pack "\\case")
|
||||||
$ docLines
|
( docSetBaseAndIndent
|
||||||
$ return <$> funcPatDocs
|
$ docNonBottomSpacing
|
||||||
)
|
$ docHandleComms lmatches
|
||||||
|
$ docLines
|
||||||
|
$ return <$> funcPatDocs
|
||||||
|
)
|
||||||
HsApp _ exp1 _ -> do
|
HsApp _ exp1 _ -> do
|
||||||
let gather
|
let gather
|
||||||
:: [(EpAnnCO, LHsExpr GhcPs)]
|
:: [(EpAnnCO, LHsExpr GhcPs)]
|
||||||
|
@ -1015,7 +1018,7 @@ recordExpression dotdot wrapO wrapDD wrapC indentPolicy _lexpr nameDoc nameLayou
|
||||||
[AddCommaAnn span] -> Just $ epaLocationRealSrcSpanStart span
|
[AddCommaAnn span] -> Just $ epaLocationRealSrcSpanStart span
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
SrcSpanAnn EpAnnNotUsed _ -> Nothing
|
SrcSpanAnn EpAnnNotUsed _ -> Nothing
|
||||||
fnameDoc <- shareDoc $ nameLayouter nameThing
|
fnameDoc <- shareDoc $ docHandleComms fEpAnn $ nameLayouter nameThing
|
||||||
if pun
|
if pun
|
||||||
then pure $ Left (posStart, fnameDoc)
|
then pure $ Left (posStart, fnameDoc)
|
||||||
else do
|
else do
|
||||||
|
|
|
@ -109,15 +109,13 @@ transformSimplifyColumns = Uniplate.rewrite $ \case
|
||||||
-> Just
|
-> Just
|
||||||
$ BDLines [BDCols sig1 (List.init cols ++ [line]), BDCols sig2 cols2]
|
$ BDLines [BDCols sig1 (List.init cols ++ [line]), BDCols sig2 cols2]
|
||||||
BDCols sig1 cols
|
BDCols sig1 cols
|
||||||
| BDPar ind line (BDLines lines) <- List.last cols
|
| BDPar _ line (BDLines lines) <- List.last cols
|
||||||
, BDCols sig2 cols2 <- List.last lines
|
, all (\case
|
||||||
, sig1 == sig2
|
BDCols sig2 _ -> sig1 == sig2
|
||||||
-> Just $ BDLines
|
_ -> False
|
||||||
[ BDCols sig1
|
)
|
||||||
$ List.init cols
|
lines
|
||||||
++ [BDPar ind line (BDLines $ List.init lines)]
|
-> Just $ BDLines $ BDCols sig1 (List.init cols ++ [line]) : lines
|
||||||
, BDCols sig2 cols2
|
|
||||||
]
|
|
||||||
BDLines [x] -> Just $ x
|
BDLines [x] -> Just $ x
|
||||||
BDLines [] -> Just $ BDEmpty
|
BDLines [] -> Just $ BDEmpty
|
||||||
BDSeq{} -> Nothing
|
BDSeq{} -> Nothing
|
||||||
|
|
|
@ -25,6 +25,7 @@ where
|
||||||
|
|
||||||
import Language.Haskell.Brittany.Internal.Prelude
|
import Language.Haskell.Brittany.Internal.Prelude
|
||||||
|
|
||||||
|
import qualified Data.Maybe
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import qualified Data.Text.Lazy.Builder as Text.Builder
|
import qualified Data.Text.Lazy.Builder as Text.Builder
|
||||||
import qualified GHC.OldList as List
|
import qualified GHC.OldList as List
|
||||||
|
@ -157,7 +158,9 @@ layoutWriteComment absolute isBlock dp commentLines s = do -- TODO92 we don't mo
|
||||||
PlannedNewline l ->
|
PlannedNewline l ->
|
||||||
if l <= y then PlannedSameline 1 else PlannedNewline (l - y)
|
if l <= y then PlannedSameline 1 else PlannedNewline (l - y)
|
||||||
PlannedDelta l i ->
|
PlannedDelta l i ->
|
||||||
if l <= y then PlannedSameline 1 else PlannedDelta (l - y) i
|
if l <= y && Data.Maybe.isNothing (_lstate_markerForDelta state)
|
||||||
|
then PlannedSameline 1
|
||||||
|
else PlannedDelta (l - y) i
|
||||||
else case _lstate_plannedSpace state of
|
else case _lstate_plannedSpace state of
|
||||||
PlannedNone -> PlannedDelta 1 (_lstate_curY state)
|
PlannedNone -> PlannedDelta 1 (_lstate_curY state)
|
||||||
PlannedSameline i -> PlannedDelta 1 (_lstate_curY state + i)
|
PlannedSameline i -> PlannedDelta 1 (_lstate_curY state + i)
|
||||||
|
|
Loading…
Reference in New Issue