Review suggestions
parent
049f286e6f
commit
9bd3bfbe4c
|
@ -14,7 +14,6 @@ module Language.Haskell.Brittany.Internal.LayouterBasics
|
||||||
, docLit
|
, docLit
|
||||||
, docAlt
|
, docAlt
|
||||||
, CollectAltM
|
, CollectAltM
|
||||||
, addAlternativeCondM
|
|
||||||
, addAlternativeCond
|
, addAlternativeCond
|
||||||
, addAlternative
|
, addAlternative
|
||||||
, runFilteredAlternative
|
, runFilteredAlternative
|
||||||
|
@ -426,10 +425,6 @@ docAlt l = allocateNode . BDFAlt =<< sequence l
|
||||||
newtype CollectAltM a = CollectAltM (Writer.Writer [ToBriDocM BriDocNumbered] a)
|
newtype CollectAltM a = CollectAltM (Writer.Writer [ToBriDocM BriDocNumbered] a)
|
||||||
deriving (Functor, Applicative, Monad)
|
deriving (Functor, Applicative, Monad)
|
||||||
|
|
||||||
addAlternativeCondM :: Bool -> CollectAltM (ToBriDocM BriDocNumbered) -> CollectAltM ()
|
|
||||||
addAlternativeCondM cond doc =
|
|
||||||
addAlternativeCond cond =<< doc
|
|
||||||
|
|
||||||
addAlternativeCond :: Bool -> ToBriDocM BriDocNumbered -> CollectAltM ()
|
addAlternativeCond :: Bool -> ToBriDocM BriDocNumbered -> CollectAltM ()
|
||||||
addAlternativeCond cond doc =
|
addAlternativeCond cond doc =
|
||||||
when cond (addAlternative doc)
|
when cond (addAlternative doc)
|
||||||
|
|
|
@ -308,14 +308,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs mWhereDocs ha
|
||||||
++ (List.intersperse docCommaSep
|
++ (List.intersperse docCommaSep
|
||||||
(docForceSingleline . return <$> gs)
|
(docForceSingleline . return <$> gs)
|
||||||
)
|
)
|
||||||
|
wherePart = case mWhereDocs of
|
||||||
indentPolicy <- mAsk
|
|
||||||
<&> _conf_layout
|
|
||||||
.> _lconfig_indentPolicy
|
|
||||||
.> confUnpack
|
|
||||||
runFilteredAlternative $ do
|
|
||||||
|
|
||||||
let wherePart = case mWhereDocs of
|
|
||||||
Nothing -> Just docEmpty
|
Nothing -> Just docEmpty
|
||||||
Just [w] -> Just $ docSeq
|
Just [w] -> Just $ docSeq
|
||||||
[ docSeparator
|
[ docSeparator
|
||||||
|
@ -323,6 +316,14 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs mWhereDocs ha
|
||||||
, docSetIndentLevel $ docForceSingleline $ return w
|
, docSetIndentLevel $ docForceSingleline $ return w
|
||||||
]
|
]
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
|
indentPolicy <- mAsk
|
||||||
|
<&> _conf_layout
|
||||||
|
.> _lconfig_indentPolicy
|
||||||
|
.> confUnpack
|
||||||
|
|
||||||
|
runFilteredAlternative $ do
|
||||||
|
|
||||||
case clauseDocs of
|
case clauseDocs of
|
||||||
[(guards, body, _bodyRaw)] -> do
|
[(guards, body, _bodyRaw)] -> do
|
||||||
let guardPart = singleLineGuardsDoc guards
|
let guardPart = singleLineGuardsDoc guards
|
||||||
|
@ -385,7 +386,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs mWhereDocs ha
|
||||||
]
|
]
|
||||||
++ wherePartMultiLine
|
++ wherePartMultiLine
|
||||||
|
|
||||||
_ -> return ()
|
_ -> return () -- no alternatives exclusively when `length clauseDocs /= 1`
|
||||||
|
|
||||||
case mPatDoc of
|
case mPatDoc of
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
|
|
|
@ -118,14 +118,15 @@ layoutLLIEs :: Bool -> Located [LIE RdrName] -> ToBriDocM BriDocNumbered
|
||||||
layoutLLIEs enableSingleline llies = do
|
layoutLLIEs enableSingleline llies = do
|
||||||
ieDs <- layoutAnnAndSepLLIEs llies
|
ieDs <- layoutAnnAndSepLLIEs llies
|
||||||
hasComments <- hasAnyCommentsBelow llies
|
hasComments <- hasAnyCommentsBelow llies
|
||||||
|
runFilteredAlternative $
|
||||||
case ieDs of
|
case ieDs of
|
||||||
[] -> runFilteredAlternative $ do
|
[] -> do
|
||||||
addAlternativeCond (not hasComments) $
|
addAlternativeCond (not hasComments) $
|
||||||
docLit $ Text.pack "()"
|
docLit $ Text.pack "()"
|
||||||
addAlternativeCond hasComments $
|
addAlternativeCond hasComments $
|
||||||
docPar (docSeq [docParenLSep, docWrapNodeRest llies docEmpty])
|
docPar (docSeq [docParenLSep, docWrapNodeRest llies docEmpty])
|
||||||
docParenR
|
docParenR
|
||||||
(ieDsH:ieDsT) -> runFilteredAlternative $ do
|
(ieDsH:ieDsT) -> do
|
||||||
addAlternativeCond (not hasComments && enableSingleline)
|
addAlternativeCond (not hasComments && enableSingleline)
|
||||||
$ docSeq
|
$ docSeq
|
||||||
$ [docLit (Text.pack "(")]
|
$ [docLit (Text.pack "(")]
|
||||||
|
|
Loading…
Reference in New Issue