@@ -190,12 +190,14 @@ vsep = foldr ($+$) empty
190chomp :: Doc -> Doc
190chomp :: Doc -> Doc
191chomp d = Doc (fromList dl')
191chomp d = Doc (fromList dl')
192 where dl = toList (unDoc d)
192 where dl = toList (unDoc d)
193− dl' = reverse $ dropWhile removeable $ reverse dl
193+ dl' = reverse $ go $ reverse dl
194− removeable BreakingSpace = True
195+ go (BreakingSpace : xs) = go xs
195− removeable CarriageReturn = True
196+ go (CarriageReturn : xs) = go xs
196− removeable NewLine = True
197+ go (NewLine : xs) = go xs
197− removeable BlankLine = True
198+ go (BlankLine : xs) = go xs
198− removeable _ = False
199+ go (Prefixed s d' : xs) = Prefixed s (chomp d') : xs
200outp :: (IsString a, Monoid a)
202outp :: (IsString a, Monoid a)
201 => Int -> String -> DocState a
203 => Int -> String -> DocState a