@@ -5,6 +5,7 @@ import Prelude.List
5import Prelude.Chars
5import Prelude.Chars
6import Prelude.Cast
6import Prelude.Cast
7import Prelude.Either
7import Prelude.Either
8+import Prelude.Foldable
9-- Some more complex string operations
10-- Some more complex string operations
@@ -38,9 +39,8 @@ unpack s with (strM s)
38 unpack "" | StrNil = []
39 unpack "" | StrNil = []
39 unpack (strCons x xs) | (StrCons x xs) = x :: unpack xs
40 unpack (strCons x xs) | (StrCons x xs) = x :: unpack xs
41−pack : List Char -> String
42+pack : (Foldable t) => t Char -> String
42−pack [] = ""
43+pack = foldr strCons ""
43−pack (x :: xs) = strCons x (pack xs)
45instance Cast String (List Char) where
45instance Cast String (List Char) where
46 cast = unpack
46 cast = unpack