diff options
| author | Jan Sucan <jan@jansucan.com> | 2023-04-10 16:49:55 +0200 |
|---|---|---|
| committer | Jan Sucan <jan@jansucan.com> | 2023-04-10 16:52:26 +0200 |
| commit | c1acd386623e0e06b9175a6f201255e310e7dad9 (patch) | |
| tree | b87df8a974c39dba9929164e252c9feae5bad745 /ch05 | |
| parent | 2c4e32dbcd6a74a93d6121212c5a44461160a38f (diff) | |
ch05: Fix compilation errors in the files from examples
Diffstat (limited to 'ch05')
| -rw-r--r-- | ch05/Prettify.hs | 8 | ||||
| -rw-r--r-- | ch05/PrettyJSON.hs | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/ch05/Prettify.hs b/ch05/Prettify.hs index 7b3ea10..c33a4ae 100644 --- a/ch05/Prettify.hs +++ b/ch05/Prettify.hs @@ -3,7 +3,7 @@ module Prettify -- * Constructors Doc -- * Basic combinators - , (<>) + , (Prettify.<>) , empty , char , text @@ -65,7 +65,7 @@ line = Line {-- snippet hcat --} hcat :: [Doc] -> Doc -hcat = fold (<>) +hcat = fold (Prettify.<>) fold :: (Doc -> Doc -> Doc) -> [Doc] -> Doc fold f = foldr f empty @@ -76,7 +76,7 @@ fsep :: [Doc] -> Doc fsep = fold (</>) (</>) :: Doc -> Doc -> Doc -x </> y = x <> softline <> y +x </> y = x Prettify.<> softline Prettify.<> y softline :: Doc softline = group line @@ -99,7 +99,7 @@ flatten other = other punctuate :: Doc -> [Doc] -> [Doc] punctuate p [] = [] punctuate p [d] = [d] -punctuate p (d:ds) = (d <> p) : punctuate p ds +punctuate p (d:ds) = (d Prettify.<> p) : punctuate p ds {-- /snippet punctuate --} {-- snippet compact --} diff --git a/ch05/PrettyJSON.hs b/ch05/PrettyJSON.hs index d9d7579..e27f01e 100644 --- a/ch05/PrettyJSON.hs +++ b/ch05/PrettyJSON.hs @@ -27,13 +27,13 @@ renderJValue (JArray ary) = series '[' ']' renderJValue ary {-- snippet renderJValue.object --} renderJValue (JObject obj) = series '{' '}' field obj where field (name,val) = string name - <> text ": " - <> renderJValue val + Prettify.<> text ": " + Prettify.<> renderJValue val {-- /snippet renderJValue.object --} {-- snippet enclose --} enclose :: Char -> Char -> Doc -> Doc -enclose left right x = char left <> x <> char right +enclose left right x = char left Prettify.<> x Prettify.<> char right {-- /snippet enclose --} {-- snippet hexEscape --} @@ -46,14 +46,14 @@ hexEscape c | d < 0x10000 = smallHex d {-- snippet smallHex --} smallHex :: Int -> Doc smallHex x = text "\\u" - <> text (replicate (4 - length h) '0') - <> text h + Prettify.<> text (replicate (4 - length h) '0') + Prettify.<> text h where h = showHex x "" {-- /snippet smallHex --} {-- snippet astral --} astral :: Int -> Doc -astral n = smallHex (a + 0xd800) <> smallHex (b + 0xdc00) +astral n = smallHex (a + 0xd800) Prettify.<> smallHex (b + 0xdc00) where a = (n `shiftR` 10) .&. 0x3ff b = n .&. 0x3ff {-- /snippet astral --} |
