[commit: pretty] master: fix up indent code (c9f3c60)
Ian Lynagh
igloo at earth.li
Sun Mar 11 12:36:45 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/pretty
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c9f3c6036aa611a18a59df12bfffdee3259ef7e9
>---------------------------------------------------------------
commit c9f3c6036aa611a18a59df12bfffdee3259ef7e9
Author: David Terei <davidterei at gmail.com>
Date: Mon Mar 5 20:42:24 2012 -0800
fix up indent code
>---------------------------------------------------------------
src/Text/PrettyPrint/HughesPJ.hs | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/Text/PrettyPrint/HughesPJ.hs b/src/Text/PrettyPrint/HughesPJ.hs
index 9f40d15..10de760 100644
--- a/src/Text/PrettyPrint/HughesPJ.hs
+++ b/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
More information about the Cvs-libraries
mailing list