Added preliminary pretty-printing support for dotted lists, but without taking into account their effect on width
Getty Ritter
8 years ago
180 | 180 | where pHead _ SNil = "()" |
181 | 181 | pHead _ (SAtom a) = atomPrinter a |
182 | 182 | pHead ind (SCons x xs) = gather ind x xs id |
183 | gather _ _ (SAtom _) _ = error "no dotted pretty printing yet!" | |
184 | 183 | gather ind h (SCons x xs) k = gather ind h xs (k . (x:)) |
185 | gather ind h SNil k = "(" <> hd <> body <> ")" | |
186 | where hd = indentSubsequent ind [pHead (ind+1) h] | |
184 | gather ind h end k = "(" <> hd <> body <> tail <> ")" | |
185 | where tail = case end of | |
186 | SNil -> "" | |
187 | SAtom a -> " . " <> atomPrinter a | |
188 | SCons _ _ -> error "[unreachable]" | |
189 | hd = indentSubsequent ind [pHead (ind+1) h] | |
187 | 190 | lst = k [] |
188 | 191 | flat = T.unwords (map (pHead (ind+1)) lst) |
189 | 192 | headWidth = T.length hd + 1 |