Ticket #3058: prettyPrintHex.patch
| File prettyPrintHex.patch, 1.0 KB (added by TomMD, 4 years ago) |
|---|
-
Text/PrettyPrint/HughesPJ.hs
old new 175 175 -- * Constructing documents 176 176 -- ** Converting values into documents 177 177 char, text, ptext, zeroWidthText, 178 int, integer, float, double, rational, 178 int, integer, float, double, rational, hex, 179 179 180 180 -- ** Simple derived documents 181 181 semi, comma, colon, space, equals, … … 214 214 215 215 216 216 import Prelude 217 import Numeric 217 218 218 219 infixl 6 <> 219 220 infixl 6 <+> … … 482 483 float n = text (show n) 483 484 double n = text (show n) 484 485 rational n = text (show n) 485 -- SIGBJORN wrote instead: 486 -- rational n = text (show (fromRationalX n)) 486 hex nr n = text . pad nr . showHex n $ "" 487 where 488 pad n s = let l = length s in if l < n then replicate (n - l) '0' ++ s else drop (l - n) s 487 489 488 490 quotes p = char '\'' <> p <> char '\'' 489 491 doubleQuotes p = char '"' <> p <> char '"'
