@@ -38,10 +38,16 @@ pack [] = ""
38pack (x :: xs) = strCons x (pack xs)
38pack (x :: xs) = strCons x (pack xs)
40instance Cast String (List Char) where
40instance Cast String (List Char) where
41− cast = unpack
41+ cast = unpack
43instance Cast (List Char) String where
43instance Cast (List Char) String where
44− cast = pack
44+ cast = pack
46+instance Semigroup String where
49+instance Monoid String where
46span : (Char -> Bool) -> String -> (String, String)
52span : (Char -> Bool) -> String -> (String, String)
47span p xs with (strM xs)
53span p xs with (strM xs)
@@ -85,18 +91,18 @@ lines : String -> List String
85lines s = map pack $ words' $ unpack s
91lines s = map pack $ words' $ unpack s
88−foldr1 : (a -> a -> a) -> List a -> a
94+foldr1 : (a -> a -> a) -> List a -> a
89foldr1 f [x] = x
95foldr1 f [x] = x
90foldr1 f (x::xs) = f x (foldr1 f xs)
96foldr1 f (x::xs) = f x (foldr1 f xs)
92%assert_total -- due to foldr1, but used safely
98%assert_total -- due to foldr1, but used safely
93unwords' : List (List Char) -> List Char
99unwords' : List (List Char) -> List Char
94−unwords' [] = []
100+unwords' [] = []
95unwords' ws = (foldr1 addSpace ws)
101unwords' ws = (foldr1 addSpace ws)
97 addSpace : List Char -> List Char -> List Char
103 addSpace : List Char -> List Char -> List Char
98− addSpace w s = w ++ (' ' :: s)
104+ addSpace w s = w ++ (' ' :: s)
100unwords : List String -> String
106unwords : List String -> String
101unwords = pack . unwords' . map unpack
107unwords = pack . unwords' . map unpack