Share some more bridoc nodes, clean up code

pull/287/head
Lennart Spitzner 2020-03-21 22:04:34 +01:00
parent 3631f6aec3
commit 2ce3fb178c
1 changed files with 15 additions and 16 deletions

View File

@ -747,23 +747,24 @@ layoutPatSynBind name patSynDetails patDir rpat = do
body = colsWrapPat =<< layoutPat rpat body = colsWrapPat =<< layoutPat rpat
whereDoc = docLit $ Text.pack "where" whereDoc = docLit $ Text.pack "where"
mWhereDocs <- layoutPatSynWhere patDir mWhereDocs <- layoutPatSynWhere patDir
runFilteredAlternative $ do headDoc <- fmap pure $ docSeq $
addAlternative $
-- pattern .. where
-- ..
-- ..
docAddBaseY BrIndentRegular $ docSeq $
[ patDoc [ patDoc
, docSeparator , docSeparator
, layoutLPatSyn name patSynDetails , layoutLPatSyn name patSynDetails
, docSeparator , docSeparator
, binderDoc , binderDoc
, docSeparator ]
, body runFilteredAlternative $ do
] ++ case mWhereDocs of addAlternative $
-- pattern .. where
-- ..
-- ..
docAddBaseY BrIndentRegular $ docSeq
( [headDoc, docSeparator, body]
++ case mWhereDocs of
Just ds -> [docSeparator, docPar whereDoc (docLines ds)] Just ds -> [docSeparator, docPar whereDoc (docLines ds)]
Nothing -> [] Nothing -> []
)
addAlternative $ addAlternative $
-- pattern .. = -- pattern .. =
-- .. -- ..
@ -772,12 +773,10 @@ layoutPatSynBind name patSynDetails patDir rpat = do
-- .. -- ..
-- .. -- ..
docAddBaseY BrIndentRegular $ docPar docAddBaseY BrIndentRegular $ docPar
(docSeq $ appSep <$> [ patDoc, layoutLPatSyn name patSynDetails, binderDoc]) headDoc
(docLines $ (case mWhereDocs of
case mWhereDocs of Nothing -> body
Nothing -> [body] Just ds -> docLines ([ docSeq [body, docSeparator, whereDoc] ] ++ ds)
Just ds ->
[ docSeq [body, docSeparator, whereDoc] ] ++ ds
) )
-- | Helper method for the left hand side of a pattern synonym -- | Helper method for the left hand side of a pattern synonym