Ticket #694: patch2

File patch2, 1.2 KB (added by maeder@…, 10 years ago)

patch 4 combinators without object code bloat

Line 
1Index: HughesPJ.hs
2===================================================================
3RCS file: /cvs/fptools/libraries/base/Text/PrettyPrint/HughesPJ.hs,v
4retrieving revision 1.17
5diff -u -r1.17 HughesPJ.hs
6--- HughesPJ.hs 22 Sep 2005 09:43:01 -0000      1.17
7+++ HughesPJ.hs 10 Feb 2006 16:01:26 -0000
8@@ -606,8 +606,13 @@
9 -- ---------------------------------------------------------------------------
10 -- Vertical composition @$$@
11 
12-p $$  q = Above p False q
13-p $+$ q = Above p True q
14+above_ :: Doc -> Bool -> Doc -> Doc
15+above_ p _ Empty = p
16+above_ Empty _ q = q
17+above_ p g q = Above p g q
18+
19+p $$  q = above_ p False q
20+p $+$ q = above_ p True q
21 
22 above :: Doc -> Bool -> RDoc -> RDoc
23 above (Above p g1 q1)  g2 q2 = above p g1 (above q1 g2 q2)
24@@ -651,8 +656,13 @@
25 -- ---------------------------------------------------------------------------
26 -- Horizontal composition @<>@
27 
28-p <>  q = Beside p False q
29-p <+> q = Beside p True  q
30+beside_ :: Doc -> Bool -> Doc -> Doc
31+beside_ p _ Empty = p
32+beside_ Empty _ q = q
33+beside_ p g q = Beside p g q
34+
35+p <>  q = beside_ p False q
36+p <+> q = beside_ p True  q
37 
38 beside :: Doc -> Bool -> RDoc -> RDoc
39 -- Specification: beside g p q = p <g> q