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