Fix layout of type-level list literal
parent
84e703d7f3
commit
2b77142617
data/11-extensions
source/library/Language/Haskell/Brittany/Internal/ToBriDoc
|
@ -8,23 +8,23 @@ test = Proxy @'[ 'True ]
|
|||
test :: Proxy '[True]
|
||||
test = Proxy @'[True]
|
||||
#test 3
|
||||
test :: Proxy '[ 'True , False ]
|
||||
test = Proxy @'[ 'True , False ]
|
||||
test :: Proxy '[ 'True, False ]
|
||||
test = Proxy @'[ 'True, False ]
|
||||
#test 4
|
||||
test :: Proxy '[True , False]
|
||||
test = Proxy @'[True , False]
|
||||
test :: Proxy '[True, False]
|
||||
test = Proxy @'[True, False]
|
||||
#test 5
|
||||
test :: Proxy '[True , 'False]
|
||||
test = Proxy @'[True , 'False]
|
||||
test :: Proxy '[True, 'False]
|
||||
test = Proxy @'[True, 'False]
|
||||
#test 6
|
||||
test :: Proxy '[ 'True , 'False ]
|
||||
test = Proxy @'[ 'True , 'False ]
|
||||
test :: Proxy '[ 'True, 'False ]
|
||||
test = Proxy @'[ 'True, 'False ]
|
||||
#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 :: Proxy '[Just True , False]
|
||||
test = Proxy @'[Just True , False]
|
||||
test :: Proxy '[Just True, False]
|
||||
test = Proxy @'[Just True, False]
|
||||
#test 9
|
||||
test :: Proxy '[('True)]
|
||||
test = Proxy @'[('True)]
|
||||
|
@ -72,3 +72,9 @@ test
|
|||
True]
|
||||
test = Proxy @'[{- comment -}
|
||||
True]
|
||||
|
||||
#test explicit-list-type non-promoted
|
||||
type Foo = '[Bool, Bool, Bool]
|
||||
|
||||
#test explicit-list-type promoted
|
||||
type Foo = '[ 'Bool, Bool, Bool ]
|
||||
|
|
|
@ -443,52 +443,46 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
|
|||
|
||||
typDocs <- typs `forM` (shareDoc . docHandleListElemComms layoutType)
|
||||
let hasComments = hasAnyCommentsBelow ltype
|
||||
docAlt
|
||||
[ docSeq
|
||||
$ [docLit $ Text.pack "'[", sepIfHeadPromoted]
|
||||
++ List.intersperse specialCommaSep (docForceSingleline <$> typDocs)
|
||||
++ [sepIfHeadPromoted, docLit $ Text.pack "]"]
|
||||
, case splitFirstLast typDocs of
|
||||
FirstLastEmpty -> docSeq
|
||||
[ docLit $ Text.pack "'[]" -- TODO92 comments AnnOpenS
|
||||
case splitFirstLast typDocs of
|
||||
FirstLastEmpty -> docSeq
|
||||
[ docLit $ Text.pack "'[]" -- TODO92 comments AnnOpenS
|
||||
]
|
||||
FirstLastSingleton e -> docAlt
|
||||
[ docSeq
|
||||
[ docLit $ Text.pack "'["
|
||||
, sepIfHeadPromoted
|
||||
, docForceSingleline e -- TODO92 comments AnnOpenS
|
||||
, sepIfHeadPromoted
|
||||
, docLit $ Text.pack "]"
|
||||
]
|
||||
FirstLastSingleton e -> docAlt
|
||||
, docSetBaseY $ docLines
|
||||
[ docSeq
|
||||
[ docLit $ Text.pack "'["
|
||||
, sepIfHeadPromoted
|
||||
, docForceSingleline e -- TODO92 comments AnnOpenS
|
||||
, sepIfHeadPromoted
|
||||
, docLit $ Text.pack "]"
|
||||
]
|
||||
, docSetBaseY $ docLines
|
||||
[ docSeq
|
||||
[ docLit $ Text.pack "'["
|
||||
, docSeparator
|
||||
, docSetBaseY $ e -- TODO92 comments AnnOpenS
|
||||
]
|
||||
, docLit $ Text.pack " ]"
|
||||
, docSeparator
|
||||
, docSetBaseY $ e -- TODO92 comments AnnOpenS
|
||||
]
|
||||
, docLit $ Text.pack " ]"
|
||||
]
|
||||
FirstLast e1 ems eN -> runFilteredAlternative $ do
|
||||
addAlternativeCond (not hasComments)
|
||||
$ docSeq
|
||||
$ [docLit $ Text.pack "'[", sepIfHeadPromoted]
|
||||
++ List.intersperse
|
||||
specialCommaSep
|
||||
(docForceSingleline
|
||||
<$> (e1 : ems ++ [eN]) -- TODO92 comments AnnOpenS
|
||||
)
|
||||
++ [docLit $ Text.pack " ]"]
|
||||
addAlternative
|
||||
$ let
|
||||
start = docCols ColList [appSep $ docLit $ Text.pack "'[", e1]
|
||||
linesM = ems <&> \d -> docCols ColList [specialCommaSep, d]
|
||||
lineN = docCols
|
||||
ColList
|
||||
[specialCommaSep, eN] -- TODO92 comments AnnOpenS
|
||||
end = docLit $ Text.pack " ]"
|
||||
in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN] ++ [end]
|
||||
]
|
||||
]
|
||||
FirstLast e1 ems eN -> runFilteredAlternative $ do
|
||||
addAlternativeCond (not hasComments)
|
||||
$ docSeq
|
||||
$ [docLit $ Text.pack "'[", sepIfHeadPromoted]
|
||||
++ List.intersperse
|
||||
docCommaSep
|
||||
(docForceSingleline
|
||||
<$> (e1 : ems ++ [eN]) -- TODO92 comments AnnOpenS
|
||||
)
|
||||
++ [sepIfHeadPromoted, docLit $ Text.pack "]"]
|
||||
addAlternative
|
||||
$ let
|
||||
start = docCols ColList [appSep $ docLit $ Text.pack "'[", e1]
|
||||
linesM = ems <&> \d -> docCols ColList [specialCommaSep, d]
|
||||
lineN = docCols
|
||||
ColList
|
||||
[specialCommaSep, eN] -- TODO92 comments AnnOpenS
|
||||
end = docLit $ Text.pack " ]"
|
||||
in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN] ++ [end]
|
||||
HsExplicitTupleTy{} -> -- TODO
|
||||
briDocByExactInlineOnly "HsExplicitTupleTy{}" ltype
|
||||
HsTyLit _ lit -> case lit of
|
||||
|
|
Loading…
Reference in New Issue