Refactor a bit more
- remove unnecessary docWrapNodeRest - make sure that sharing is correct and non-redundantpull/83/head
parent
33f23a65ec
commit
82a5ffb3b3
|
@ -69,18 +69,18 @@ layoutIE lie@(L _ ie) = docWrapNode lie $ case ie of
|
||||||
-- This configuration allows both vertical and horizontal
|
-- This configuration allows both vertical and horizontal
|
||||||
-- handling of the resulting list. Adding parens is
|
-- handling of the resulting list. Adding parens is
|
||||||
-- left to the caller since that is context sensitive
|
-- left to the caller since that is context sensitive
|
||||||
layoutAnnAndSepLLIEs :: (Located [LIE RdrName]) -> ToBriDocM [ToBriDocM BriDocNumbered]
|
layoutAnnAndSepLLIEs
|
||||||
|
:: Located [LIE RdrName] -> ToBriDocM [ToBriDocM BriDocNumbered]
|
||||||
layoutAnnAndSepLLIEs llies@(L _ lies) = do
|
layoutAnnAndSepLLIEs llies@(L _ lies) = do
|
||||||
let
|
let makeIENode ie = docSeq [docCommaSep, ie]
|
||||||
makeIENode ie = docSeq [docCommaSep, ie]
|
let ieDocs = layoutIE <$> lies
|
||||||
layoutAnnAndSepLLIEs' ies = case splitFirstLast ies of
|
ieCommaDocs <-
|
||||||
|
docWrapNodeRest llies $ sequence $ case splitFirstLast ieDocs of
|
||||||
FirstLastEmpty -> []
|
FirstLastEmpty -> []
|
||||||
FirstLastSingleton ie -> [docWrapNodeRest llies $ ie]
|
FirstLastSingleton ie -> [ie]
|
||||||
FirstLast ie1 ieMs ieN ->
|
FirstLast ie1 ieMs ieN ->
|
||||||
[ie1]
|
[ie1] ++ map makeIENode ieMs ++ [makeIENode ieN]
|
||||||
++ map makeIENode ieMs
|
pure $ fmap pure ieCommaDocs -- returned shared nodes
|
||||||
++ [makeIENode $ docWrapNodeRest llies $ ieN]
|
|
||||||
layoutAnnAndSepLLIEs' <$> mapM (docSharedWrapper layoutIE) lies
|
|
||||||
|
|
||||||
-- Builds a complete layout for the given located
|
-- Builds a complete layout for the given located
|
||||||
-- list of LIEs. The layout provides two alternatives:
|
-- list of LIEs. The layout provides two alternatives:
|
||||||
|
@ -92,7 +92,7 @@ layoutAnnAndSepLLIEs llies@(L _ lies) = do
|
||||||
-- )
|
-- )
|
||||||
-- Empty lists will always be rendered as ()
|
-- Empty lists will always be rendered as ()
|
||||||
layoutLLIEs :: Located [LIE RdrName] -> ToBriDocM BriDocNumbered
|
layoutLLIEs :: Located [LIE RdrName] -> ToBriDocM BriDocNumbered
|
||||||
layoutLLIEs llies = docWrapNodeRest llies $ do
|
layoutLLIEs llies = do
|
||||||
ieDs <- layoutAnnAndSepLLIEs llies
|
ieDs <- layoutAnnAndSepLLIEs llies
|
||||||
case ieDs of
|
case ieDs of
|
||||||
[] -> docLit $ Text.pack "()"
|
[] -> docLit $ Text.pack "()"
|
||||||
|
|
Loading…
Reference in New Issue