@@ -3,11 +3,10 @@ module String where
33are enclosed in `"double quotes"`. Strings are *not* lists of characters.
44
55# Basics
6−@docs isEmpty, length, cons, uncons, reverse,
7− map, filter, foldl, foldr, any, all, repeat
6+@docs isEmpty, length, reverse, repeat
87
9−# Split and Join
10−@docs split, join, words, lines
8+# Building and Splitting
9+@docs cons, uncons, append, concat, split, join, words, lines
1110
1211# Get Substrings
1312@docs sub, left, right, dropLeft, dropRight
@@ -15,8 +14,8 @@ are enclosed in `"double quotes"`. Strings are *not* lists of characters.
1514# Check for Substrings
1615@docs contains, startsWith, endsWith, indexes, indices
1716
18−# Conversion To Numbers
19−@docs toInt, toFloat
17+# Conversions
18+@docs toInt, toFloat, toList, fromList
2019
2120# Formatting
2221Cosmetic operations such as padding with extra characters or trimming whitespace.
@@ -24,6 +23,9 @@ Cosmetic operations such as padding with extra characters or trimming whitespace
2423@docs toUpper, toLower,
2524 pad, padLeft, padRight,
2625 trim, trimLeft, trimRight
26+
27+# Higher-Order Functions
28+@docs map, filter, foldl, foldr, any, all
2729-}
2830
2931import Native.String
@@ -46,6 +48,21 @@ pattern match on strings exactly as you would with lists.
4648uncons : String -> Maybe (Char, String)
4749uncons = Native.String.uncons
4850
51+{-| Append two strings. You can also use [the `(++)` operator](/library/List.elm#++)
52+to do this.
53+
54+ append "butter" "fly" == "butterfly"
55+-}
56+append : String -> String -> String
57+append = Native.String.append
58+
59+{-| Concatenate many strings into one.
60+
61+ concat ["never","the","less"] == "nevertheless"
62+-}
63+concat : [String] -> String
64+concat = Native.String.concat
65+
4966{-| Get the length of a string `(length "innumerable" == 11)` -}
5067length : String -> Int
5168length = Native.String.length
@@ -68,12 +85,16 @@ filter = Native.String.filter
6885reverse : String -> String
6986reverse = Native.String.reverse
7087
71−{-|
88+{-| Reduce a string from the left:
89+
90+ foldl cons "" "time" == "emit"
7291-}
7392foldl : (Char -> b -> b) -> b -> String -> b
7493foldl = Native.String.foldl
7594
76−{-|
95+{-| Reduce a string from the right:
96+
97+ foldr cons "" "time" == "time"
7798-}
7899foldr : (Char -> b -> b) -> b -> String -> b
79100foldr = Native.String.foldr
@@ -272,3 +293,19 @@ toInt = Native.String.toInt
272293-}
273294toFloat : String -> Maybe Float
274295toFloat = Native.String.toFloat
296+
297+{-| Convert a string to a list of characters.
298+
299+ toList "abc" == ['a','b','c']
300+-}
301+toList : String -> [Char]
302+toList = Native.String.toList
303+
304+{-| Convert a list of characters into a String. Can be useful if you
305+want to create a string primarly by consing, perhaps for decoding
306+something.
307+
308+ fromList ['a','b','c'] == "abc"
309+-}
310+fromList : String -> [Char]
311+fromList = Native.String.fromList