lawbreakers in Text.PrettyPrint.HughesPJ
Christian Maeder
maeder at tzi.de
Fri Nov 25 09:40:22 EST 2005
Christian Maeder wrote:
> @@ -607,8 +611,13 @@
Myline number may be wrong, because I used an older version of the
module. After the introduction of above_ and beside_ it also makes sense
to move the call of reduceDoc to the last argument (and remove this
calls in reduceDoc and above). The patch for this is below. I cannot
observe speed differences, though.
Christian
@@ -461,8 +461,8 @@
type RDoc = Doc
reduceDoc :: Doc -> RDoc
-reduceDoc (Beside p g q) = beside p g (reduceDoc q)
-reduceDoc (Above p g q) = above p g (reduceDoc q)
+reduceDoc (Beside p g q) = beside p g q
+reduceDoc (Above p g q) = above p g q
reduceDoc p = p
@@ -562,15 +562,15 @@
above_ :: Doc -> Bool -> Doc -> Doc
above_ Empty _ q = q
above_ p _ Empty = p
-above_ p g q = Above p g q
+above_ p g q = Above p g (reduceDoc q)
p $$ q = above_ p False q
p $+$ q = above_ p True q
above :: Doc -> Bool -> RDoc -> RDoc
above (Above p g1 q1) g2 q2 = above p g1 (above q1 g2 q2)
-above p@(Beside _ _ _) g q = aboveNest (reduceDoc p) g 0 (reduceDoc q)
-above p g q = aboveNest p g 0 (reduceDoc q)
+above p@(Beside _ _ _) g q = aboveNest (reduceDoc p) g 0 q
+above p g q = aboveNest p g 0 q
aboveNest :: RDoc -> Bool -> Int -> RDoc -> RDoc
-- Specfication: aboveNest p g k q = p $g$ (nest k q)
@@ -614,7 +614,7 @@
beside_ :: Doc -> Bool -> Doc -> Doc
beside_ Empty _ q = q
beside_ p _ Empty = p
-beside_ p g q = Beside p g q
+beside_ p g q = Beside p g (reduceDoc q)
p <> q = beside_ p False q
p <+> q = beside_ p True q
More information about the Libraries
mailing list