11 | dropWhile1 : (a -> Bool) -> List1 a -> List1 a
12 | dropWhile1 f (h ::: t) = h ::: dropWhile f t
14 | noTrailingSpace : List Char -> List Char
15 | noTrailingSpace = reverse . dropWhile isSpace . reverse
17 | noTrailingNewlines : List1 (List Char) -> List1 (List Char)
18 | noTrailingNewlines = reverse . dropWhile1 (\x => null x) . cons [] . reverse
21 | unlinesImpl : List1 (List Char) -> List Char
22 | unlinesImpl ([] ::: []) = [NL]
23 | unlinesImpl (h ::: t) = h ++ run t
26 | run : List (List Char) -> List Char
28 | run (cs :: css) = NL :: cs ++ run css
31 | removeCRLF : List Char -> List Char
33 | removeCRLF ('\r' :: '\n' :: xs) = '\n' :: removeCRLF xs
34 | removeCRLF (x :: xs) = x :: removeCRLF xs
36 | transformImpl : List Char -> List Char
39 | . noTrailingNewlines
40 | . map noTrailingSpace
50 | transform : String -> String
51 | transform = fastPack . transformImpl . fastUnpack
57 | TestNoTrailingSpace : String -> String
58 | TestNoTrailingSpace = pack . noTrailingSpace . unpack
60 | noTrailingTest0 : TestNoTrailingSpace "" = ""
61 | noTrailingTest0 = Refl
63 | noTrailingTest1 : TestNoTrailingSpace "a test " = "a test"
64 | noTrailingTest1 = Refl
66 | noTrailingTest2 : TestNoTrailingSpace "a test\t \t" = "a test"
67 | noTrailingTest2 = Refl
69 | noTrailingTest3 : TestNoTrailingSpace "a test" = "a test"
70 | noTrailingTest3 = Refl
72 | TestTransformImpl : String -> String
73 | TestTransformImpl = pack . transformImpl . unpack
75 | transTest0 : TestTransformImpl "" = "\n"
78 | transTest1 : TestTransformImpl "test" = "test\n"
81 | transTest2 : TestTransformImpl "test\n\n" = "test\n"
84 | transTest3 : TestTransformImpl "test\ntrailing \n\n" = "test\ntrailing\n"
87 | transTest4 : TestTransformImpl "test\ntrailing \t" = "test\ntrailing\n"
90 | transTest5 : TestTransformImpl "test\r\ntrailing" = "test\ntrailing\n"
93 | Empties : List String
103 | testEmpties : map TestTransformImpl Empties = replicate (length Empties) "\n"