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
headDoc <- fmap pure $ docSeq $
[ patDoc
, docSeparator
, layoutLPatSyn name patSynDetails
, docSeparator
, binderDoc
]
runFilteredAlternative $ do runFilteredAlternative $ do
addAlternative $ addAlternative $
-- pattern .. where -- pattern .. where
-- .. -- ..
-- .. -- ..
docAddBaseY BrIndentRegular $ docSeq $ docAddBaseY BrIndentRegular $ docSeq
[ patDoc ( [headDoc, docSeparator, body]
, docSeparator ++ case mWhereDocs of
, layoutLPatSyn name patSynDetails
, docSeparator
, binderDoc
, 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