lawbreakers in Text.PrettyPrint.HughesPJ
Christian Maeder
maeder at tzi.de
Fri Nov 25 09:02:10 EST 2005
Simon Peyton-Jones wrote:
> It's a long time since I looked at this library. If you two can agree
> on what needs to be done, I'll gladly execute the change!
I've tried both versions, without noticing a difference. So take the
following patch (as suggested by Conal).
Cheers Christian
--
---------------------------------------------------------------------------
-- Vertical composition @$$@
-p $$ q = Above p False q
-p $+$ q = Above p True q
+above_ :: Doc -> Bool -> Doc -> Doc
+above_ Empty _ q = q
+above_ p _ Empty = p
+above_ p g q = Above p g 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)
@@ -607,8 +611,13 @@
--
---------------------------------------------------------------------------
-- Horizontal composition @<>@
-p <> q = Beside p False q
-p <+> q = Beside p True q
+beside_ :: Doc -> Bool -> Doc -> Doc
+beside_ Empty _ q = q
+beside_ p _ Empty = p
+beside_ p g q = Beside p g q
+
+p <> q = beside_ p False q
+p <+> q = beside_ p True q
beside :: Doc -> Bool -> RDoc -> RDoc
-- Specification: beside g p q = p <g> q
More information about the Libraries
mailing list