@@ -11,14 +11,17 @@ data StrM : String -> Set where
1111 StrNil : StrM ""
1212 StrCons : (x : Char) -> (xs : String) -> StrM (strCons x xs)
1313
14+%assert_total
1415strHead' : (x : String) -> so (not (x == "")) -> Char
1516strHead' x p = prim__strHead x
1617
18+%assert_total
1719strTail' : (x : String) -> so (not (x == "")) -> String
1820strTail' x p = prim__strTail x
1921
2022-- we need the 'believe_me' because the operations are primitives
2123
24+%assert_total
2225strM : (x : String) -> StrM x
2326strM x with (choose (not (x == "")))
2427 strM x | (Left p) = believe_me $ StrCons (strHead' x p) (strTail' x p)
@@ -71,11 +74,12 @@ words' s = case dropWhile isSpace s of
7174words : String -> List String
7275words s = map pack $ words' $ unpack s
7376
77+partial
7478foldr1 : (a -> a -> a) -> List a -> a
7579foldr1 f [x] = x
7680foldr1 f (x::xs) = f x (foldr1 f xs)
7781
78−
82+%assert_total -- due to foldr1, but used safely
7983unwords' : List (List Char) -> List Char
8084unwords' [] = []
8185unwords' ws = (foldr1 addSpace ws)
@@ -83,7 +87,6 @@ unwords' ws = (foldr1 addSpace ws)
8387 addSpace : List Char -> List Char -> List Char
8488 addSpace w s = w ++ (' ' :: s)
8589
86−
87−unwords : List String -> String
90+unwords : List String -> String
8891unwords = pack . unwords' . map unpack
8992