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

@ -8,23 +8,23 @@ test = Proxy @'[ 'True ]
test :: Proxy '[True] test :: Proxy '[True]
test = Proxy @'[True] test = Proxy @'[True]
#test 3 #test 3
test :: Proxy '[ 'True , False ] test :: Proxy '[ 'True, False ]
test = Proxy @'[ 'True , False ] test = Proxy @'[ 'True, False ]
#test 4 #test 4
test :: Proxy '[True , False] test :: Proxy '[True, False]
test = Proxy @'[True , False] test = Proxy @'[True, False]
#test 5 #test 5
test :: Proxy '[True , 'False] test :: Proxy '[True, 'False]
test = Proxy @'[True , 'False] test = Proxy @'[True, 'False]
#test 6 #test 6
test :: Proxy '[ 'True , 'False ] test :: Proxy '[ 'True, 'False ]
test = Proxy @'[ 'True , 'False ] test = Proxy @'[ 'True, 'False ]
#test 7 #test 7
test :: Proxy '[ 'Just 'True , False ] test :: Proxy '[ 'Just 'True, False ]
test = Proxy @'[ 'Just 'True , False ] test = Proxy @'[ 'Just 'True, False ]
#test 8 #test 8
test :: Proxy '[Just True , False] test :: Proxy '[Just True, False]
test = Proxy @'[Just True , False] test = Proxy @'[Just True, False]
#test 9 #test 9
test :: Proxy '[('True)] test :: Proxy '[('True)]
test = Proxy @'[('True)] test = Proxy @'[('True)]
@ -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