Ticket #3058: prettyNumeric.patch

File prettyNumeric.patch, 6.1 KB (added by TomMD, 6 years ago)

The Numeric patch adding ord, hex, etc.

Line 
1Mon Mar  2 10:40:22 PST 2009  [email protected]
2  * Remove commented out code - that is what a repository is for.
3
4Mon Mar  2 17:10:01 PST 2009  [email protected]
5  * Add the equivilant of the Numeric.show* functions (hex, oct, intAtBase, {e,f,g}float, and padded versions.
6
7Mon Mar  2 17:50:09 PST 2009  [email protected]
8  * Rework float functions from Numeric
9
10Sat Mar 14 17:22:41 PDT 2009  [email protected]
11  * Dumb typo variable 'l' does not equal numeric '1'.
12
13New patches:
14
15[Remove commented out code - that is what a repository is for.
16[email protected]**20090302184022
17 Ignore-this: b1b1cbdd0b639ed819587b4c73ae5789
18] hunk ./Text/PrettyPrint/HughesPJ.hs 485
19 float    n = text (show n)
20 double   n = text (show n)
21 rational n = text (show n)
22--- SIGBJORN wrote instead:
23--- rational n = text (show (fromRationalX n))
24 
25 quotes p        = char '\'' <> p <> char '\''
26 doubleQuotes p  = char '"' <> p <> char '"'
27[Add the equivilant of the Numeric.show* functions (hex, oct, intAtBase, {e,f,g}float, and padded versions.
28[email protected]**20090303011001
29 Ignore-this: c761b6fb8848e191523921e5ed97eda1
30] {
31hunk ./Text/PrettyPrint/HughesPJ.hs 180
32         char, text, ptext, zeroWidthText,
33         int, integer, float, double, rational,
34 
35+       hex, hexPad, oct, octPad, intAtBase, intAtBasePad,
36+       efloat, ffloat, gfloat,
37+
38        -- ** Simple derived documents
39         semi, comma, colon, space, equals,
40         lparen, rparen, lbrack, rbrack, lbrace, rbrace,
41hunk ./Text/PrettyPrint/HughesPJ.hs 220
42 
43 
44 import Prelude
45+import Numeric
46 
47 infixl 6 <>
48 infixl 6 <+>
49hunk ./Text/PrettyPrint/HughesPJ.hs 489
50 float    n = text (show n)
51 double   n = text (show n)
52 rational n = text (show n)
53+hex      n = text (showHex n "")
54+efloat   n = text (showEFloat Nothing n "")
55+ffloat   n = text (showFFloat Nothing n "")
56+gfloat   n = text (showGFloat Nothing n "")
57+intAtBase b r n = text (showIntAtBase b r n "")
58+oct      n = text (showOct n "")
59+
60+hexPad n p = text . pad p '0' . showHex n $ ""
61+octPad n p = text . pad p '0' . showOct n $ ""
62+intAtBasePad b r n p = text . pad p '0' . showIntAtBase b r n $ ""
63+pad n c s = let l = length s in if l < n then replicate (n - 1) c ++ s else drop (l - n) s
64 
65 quotes p        = char '\'' <> p <> char '\''
66 doubleQuotes p  = char '"' <> p <> char '"'
67}
68[Rework float functions from Numeric
69[email protected]**20090303015009
70 Ignore-this: 437277a9b534b8a7765d8fa0714c609d
71] {
72hunk ./Text/PrettyPrint/HughesPJ.hs 490
73 double   n = text (show n)
74 rational n = text (show n)
75 hex      n = text (showHex n "")
76-efloat   n = text (showEFloat Nothing n "")
77-ffloat   n = text (showFFloat Nothing n "")
78-gfloat   n = text (showGFloat Nothing n "")
79 intAtBase b r n = text (showIntAtBase b r n "")
80 oct      n = text (showOct n "")
81 
82hunk ./Text/PrettyPrint/HughesPJ.hs 493
83+-- |Shows floats in scientific notation with precision p
84+efloat   p n = text (showEFloat p n "")
85+
86+-- |Shows floats in decimal notation with precision p
87+ffloat   p n = text (showFFloat p n "")
88+
89+-- |Shows floats in decimal notation when between 0.1 and 9,999,999.  Scientific notation otherwise.
90+gfloat   p n = text (showGFloat p n "")
91+
92+-- |Shows a potentially signed value, n, up to precision p.  The function 'f' is used for unsigned values.
93+signed f p n = text (showSigned f p n "")
94+
95+-- |Shows 'n' in base 16, padding (with 0) the result to 'p' characters.  When the result is over 'p' characters
96+-- only 'p' least significate nibbles are returned.
97 hexPad n p = text . pad p '0' . showHex n $ ""
98hunk ./Text/PrettyPrint/HughesPJ.hs 508
99+
100+-- |Shows 'n' in base 8, with padding or roll-over behavior matching 'hexPad'.
101+-- only 'p' least significate nibbles are returned.
102 octPad n p = text . pad p '0' . showOct n $ ""
103hunk ./Text/PrettyPrint/HughesPJ.hs 512
104+
105+-- |Shows 'n' in base 'b' using function 'r' to translate the values to characters.
106+-- The number of digits is trunkated or padded to 'p' characters, as in hexPad and octPad.
107 intAtBasePad b r n p = text . pad p '0' . showIntAtBase b r n $ ""
108hunk ./Text/PrettyPrint/HughesPJ.hs 516
109+
110 pad n c s = let l = length s in if l < n then replicate (n - 1) c ++ s else drop (l - n) s
111 
112 quotes p        = char '\'' <> p <> char '\''
113}
114[Dumb typo variable 'l' does not equal numeric '1'.
115[email protected]**20090315002241
116 Ignore-this: 7b79f8ce8cbc8556fb6b0a66e203c196
117] hunk ./Text/PrettyPrint/HughesPJ.hs 517
118 -- The number of digits is trunkated or padded to 'p' characters, as in hexPad and octPad.
119 intAtBasePad b r n p = text . pad p '0' . showIntAtBase b r n $ ""
120 
121-pad n c s = let l = length s in if l < n then replicate (n - 1) c ++ s else drop (l - n) s
122+pad n c s = let l = length s in if l < n then replicate (n - l) c ++ s else drop (l - n) s
123 
124 quotes p        = char '\'' <> p <> char '\''
125 doubleQuotes p  = char '"' <> p <> char '"'
126
127Context:
128
129[Require Cabal version >= 1.6
130Ian Lynagh <[email protected]>**20090122011320]
131[Add "bug-reports" and "source-repository" info to the Cabal file
132Ian Lynagh <[email protected]>**20090121182635
133 Also switched to the modern Cabal file format
134]
135[Bump version number to 1.0.1.0
136Ian Lynagh <[email protected]>**20080920160835]
137[TAG 6.10 branch has been forked
138Ian Lynagh <[email protected]>**20080919123438]
139[add category field
140Ross Paterson <[email protected]>**20080824003013]
141[Fix warnings and change a comment that was confusing haddock
142Ian Lynagh <[email protected]>**20080706151335]
143[Merge the rest of Benedikt Huber's "Fix HughesPJ developer documentation."
144Ian Lynagh <[email protected]>**20080706134923]
145[Merge the rest of Benedikt Huber's "Fix bug #1337, #2391 1,2"
146Ian Lynagh <[email protected]>**20080706133005]
147[Adds a `zeroWidthText' primitive to the library, in order to create text
148[email protected]**20080626161647
149 which occupies no space (e.g. html or latex tags).
150]
151[Add a type-sig - fixes validating
152Ian Lynagh <[email protected]>**20080629225420]
153[fillNB bug, lazy vcat
154[email protected]**20080624113715]
155[Fix warnings
156Ian Lynagh <[email protected]>**20080620135156]
157[TAG 2008-05-28
158Ian Lynagh <[email protected]>**20080528004408]
159Patch bundle hash:
1600a8ae49f52f1f1a72d866fa89c0eef58d9d35ed8