Fix layout of type-level list literal

ghc92
Lennart Spitzner 2023-05-03 19:53:19 +00:00
parent 84e703d7f3
commit 2b77142617
2 changed files with 53 additions and 53 deletions

View File

@ -72,3 +72,9 @@ test
True] True]
test = Proxy @'[{- comment -} test = Proxy @'[{- comment -}
True] True]
#test explicit-list-type non-promoted
type Foo = '[Bool, Bool, Bool]
#test explicit-list-type promoted
type Foo = '[ 'Bool, Bool, Bool ]

View File

@ -443,12 +443,7 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
typDocs <- typs `forM` (shareDoc . docHandleListElemComms layoutType) typDocs <- typs `forM` (shareDoc . docHandleListElemComms layoutType)
let hasComments = hasAnyCommentsBelow ltype let hasComments = hasAnyCommentsBelow ltype
docAlt case splitFirstLast typDocs of
[ docSeq
$ [docLit $ Text.pack "'[", sepIfHeadPromoted]
++ List.intersperse specialCommaSep (docForceSingleline <$> typDocs)
++ [sepIfHeadPromoted, docLit $ Text.pack "]"]
, case splitFirstLast typDocs of
FirstLastEmpty -> docSeq FirstLastEmpty -> docSeq
[ docLit $ Text.pack "'[]" -- TODO92 comments AnnOpenS [ docLit $ Text.pack "'[]" -- TODO92 comments AnnOpenS
] ]
@ -474,11 +469,11 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
$ docSeq $ docSeq
$ [docLit $ Text.pack "'[", sepIfHeadPromoted] $ [docLit $ Text.pack "'[", sepIfHeadPromoted]
++ List.intersperse ++ List.intersperse
specialCommaSep docCommaSep
(docForceSingleline (docForceSingleline
<$> (e1 : ems ++ [eN]) -- TODO92 comments AnnOpenS <$> (e1 : ems ++ [eN]) -- TODO92 comments AnnOpenS
) )
++ [docLit $ Text.pack " ]"] ++ [sepIfHeadPromoted, docLit $ Text.pack "]"]
addAlternative addAlternative
$ let $ let
start = docCols ColList [appSep $ docLit $ Text.pack "'[", e1] start = docCols ColList [appSep $ docLit $ Text.pack "'[", e1]
@ -488,7 +483,6 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
[specialCommaSep, eN] -- TODO92 comments AnnOpenS [specialCommaSep, eN] -- TODO92 comments AnnOpenS
end = docLit $ Text.pack " ]" end = docLit $ Text.pack " ]"
in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN] ++ [end] in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN] ++ [end]
]
HsExplicitTupleTy{} -> -- TODO HsExplicitTupleTy{} -> -- TODO
briDocByExactInlineOnly "HsExplicitTupleTy{}" ltype briDocByExactInlineOnly "HsExplicitTupleTy{}" ltype
HsTyLit _ lit -> case lit of HsTyLit _ lit -> case lit of