@@ -3,11 +3,10 @@ module String where
3are enclosed in `"double quotes"`. Strings are *not* lists of characters.
3are enclosed in `"double quotes"`. Strings are *not* lists of characters.
6−@docs isEmpty, length, cons, uncons, reverse,
6+@docs isEmpty, length, reverse, repeat
7− map, filter, foldl, foldr, any, all, repeat
9−# Split and Join
8+# Building and Splitting
10−@docs split, join, words, lines
9+@docs cons, uncons, append, concat, split, join, words, lines
12# Get Substrings
11# Get Substrings
13@docs sub, left, right, dropLeft, dropRight
12@docs sub, left, right, dropLeft, dropRight
@@ -15,8 +14,8 @@ are enclosed in `"double quotes"`. Strings are *not* lists of characters.
15# Check for Substrings
14# Check for Substrings
16@docs contains, startsWith, endsWith, indexes, indices
15@docs contains, startsWith, endsWith, indexes, indices
18−# Conversion To Numbers
17+# Conversions
19−@docs toInt, toFloat
18+@docs toInt, toFloat, toList, fromList
21# Formatting
20# Formatting
22Cosmetic operations such as padding with extra characters or trimming whitespace.
21Cosmetic 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
24@docs toUpper, toLower,
23@docs toUpper, toLower,
25 pad, padLeft, padRight,
24 pad, padLeft, padRight,
26 trim, trimLeft, trimRight
25 trim, trimLeft, trimRight
27+# Higher-Order Functions
28+@docs map, filter, foldl, foldr, any, all
29import Native.String
31import Native.String
@@ -46,6 +48,21 @@ pattern match on strings exactly as you would with lists.
46uncons : String -> Maybe (Char, String)
48uncons : String -> Maybe (Char, String)
47uncons = Native.String.uncons
49uncons = Native.String.uncons
51+{-| Append two strings. You can also use [the `(++)` operator](/library/List.elm#++)
54+ append "butter" "fly" == "butterfly"
56+append : String -> String -> String
57+append = Native.String.append
59+{-| Concatenate many strings into one.
61+ concat ["never","the","less"] == "nevertheless"
63+concat : [String] -> String
64+concat = Native.String.concat
49{-| Get the length of a string `(length "innumerable" == 11)` -}
66{-| Get the length of a string `(length "innumerable" == 11)` -}
50length : String -> Int
67length : String -> Int
51length = Native.String.length
68length = Native.String.length
@@ -68,12 +85,16 @@ filter = Native.String.filter
68reverse : String -> String
85reverse : String -> String
69reverse = Native.String.reverse
86reverse = Native.String.reverse
71−{-|
88+{-| Reduce a string from the left:
90+ foldl cons "" "time" == "emit"
73foldl : (Char -> b -> b) -> b -> String -> b
92foldl : (Char -> b -> b) -> b -> String -> b
74foldl = Native.String.foldl
93foldl = Native.String.foldl
76−{-|
95+{-| Reduce a string from the right:
97+ foldr cons "" "time" == "time"
78foldr : (Char -> b -> b) -> b -> String -> b
99foldr : (Char -> b -> b) -> b -> String -> b
79foldr = Native.String.foldr
100foldr = Native.String.foldr
@@ -272,3 +293,19 @@ toInt = Native.String.toInt
273toFloat : String -> Maybe Float
294toFloat : String -> Maybe Float
274toFloat = Native.String.toFloat
295toFloat = Native.String.toFloat
297+{-| Convert a string to a list of characters.
299+ toList "abc" == ['a','b','c']
301+toList : String -> [Char]
302+toList = Native.String.toList
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
308+ fromList ['a','b','c'] == "abc"
310+fromList : String -> [Char]
311+fromList = Native.String.fromList