Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix up indent code

  • Loading branch information...
commit c9f3c6036aa611a18a59df12bfffdee3259ef7e9 1 parent ea24682
David Terei authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/Text/PrettyPrint/HughesPJ.hs
View
11 src/Text/PrettyPrint/HughesPJ.hs
@@ -279,10 +279,11 @@ isEmpty :: Doc -> Bool
isEmpty Empty = True
isEmpty _ = False
+-- | Produce spacing for indenting the amount specified.
+--
-- an old version inserted tabs being 8 columns apart in the output.
-indent :: Int -> TextDetails
-indent n | n >= 8 = Str " " `txt` indent (n - 8)
- | otherwise = Str $ replicate n ' '
+indent :: Int -> String
+indent !n = replicate n ' '
{-
Q: What is the reason for negative indentation (i.e. argument to indent
@@ -527,7 +528,7 @@ nilAboveNest _ _ Empty = Empty
-- Here's why the "text s <>" is in the spec!
nilAboveNest g k (Nest k1 q) = nilAboveNest g (k + k1) q
nilAboveNest g k q | not g && k > 0 -- No newline if no overlap
- = textBeside_ (indent k) k q
+ = textBeside_ (Str (indent k)) k q
| otherwise -- Put them really above
= nilAbove_ (mkNest k q)
@@ -886,7 +887,7 @@ display m !page_width !ribbon_width txt end doc
lay _ (Union {}) = error "display lay Union"
lay1 !k s !sl p = let !r = k + sl
- in indent k `txt` (s `txt` lay2 r p)
+ in Str (indent k) `txt` (s `txt` lay2 r p)
lay2 k _ | k `seq` False = undefined
lay2 k (NilAbove p) = nl_text `txt` lay k p
Please sign in to comment.
Something went wrong with that request. Please try again.