on master help sign in
Change Prelude.Strings.pack to apply to Foldable
commit60cc64edf6e65d3f2cbb6aa808ea7af4701557cb authorMelvar Chen <Melvar.Chen@googlemail.com> dateWed 13 Nov 2013, 16:15 (13 years ago) parent3c2443e
1 file changed+3−3
lib/Prelude/Strings.idr+3−3
lib/Prelude/Strings.idr+3−3
@@ -5,6 +5,7 @@ import Prelude.List
55import Prelude.Chars
66import Prelude.Cast
77import Prelude.Either
8+import Prelude.Foldable
89
910-- Some more complex string operations
1011
@@ -38,9 +39,8 @@ unpack s with (strM s)
3839 unpack "" | StrNil = []
3940 unpack (strCons x xs) | (StrCons x xs) = x :: unpack xs
4041
41−pack : List Char -> String
42−pack [] = ""
43−pack (x :: xs) = strCons x (pack xs)
42+pack : (Foldable t) => t Char -> String
43+pack = foldr strCons ""
4444
4545instance Cast String (List Char) where
4646 cast = unpack