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