Simon Peyton Jones pushed to branch wip/T23162-spj at Glasgow Haskell Compiler / GHC
Commits:
-
164590b5
by Simon Peyton Jones at 2025-08-16T00:09:40+01:00
1 changed file:
Changes:
| ... | ... | @@ -528,19 +528,22 @@ pprDeeperList f ds |
| 528 | 528 | | null ds = f []
|
| 529 | 529 | | otherwise = SDoc work
|
| 530 | 530 | where
|
| 531 | - work ctx@SDC{ sdocStyle=PprUser _ (PartWay {}) _ }
|
|
| 532 | - = let -- Only do this depth-limitation in User style
|
|
| 533 | - -- when PartWay is on. Why not for DefaultDepth?
|
|
| 534 | - -- I have no idea; seems like a bug to me.
|
|
| 535 | - go _ [] = []
|
|
| 536 | - go i (d:ds) | i >= default_depth = [text "...."]
|
|
| 537 | - | otherwise = d : go (i+1) ds
|
|
| 538 | - in runSDoc (f (go 0 ds)) ctx
|
|
| 539 | - where
|
|
| 540 | - default_depth = sdocDefaultDepth ctx
|
|
| 531 | + -- Trim the list to the length of the remaining depth count
|
|
| 532 | + work ctx@SDC{ sdocStyle=PprUser _ depth _ }
|
|
| 533 | + | Just list_elts_to_print
|
|
| 534 | + <- case depth of
|
|
| 535 | + DefaultDepth -> Just (sdocDefaultDepth ctx)
|
|
| 536 | + PartWay n -> Just n
|
|
| 537 | + AllTheWay -> Nothing
|
|
| 538 | + = runSDoc (f (trim list_elts_to_print ds)) ctx
|
|
| 541 | 539 | |
| 542 | 540 | work other_ctx = runSDoc (f ds) other_ctx
|
| 543 | 541 | |
| 542 | +trim :: Int -> [SDoc] -> [SDoc]
|
|
| 543 | +trim _ [] = []
|
|
| 544 | +trim 0 _ = [text "...."]
|
|
| 545 | +trim n (d:ds) = d : trim (n-1) ds
|
|
| 546 | + |
|
| 544 | 547 | pprSetDepth :: Depth -> SDoc -> SDoc
|
| 545 | 548 | pprSetDepth depth doc = SDoc $ \ctx ->
|
| 546 | 549 | case ctx of
|