on master help sign in
Add String as a proper Elm library, remove alias to [Char]
commit51413f92e3e4ee3e3ec5892deb6904dba1a8c717 authorEvan Czaplicki <info@elm-lang.org> dateWed 2 Oct 2013, 15:21 (13 years ago) parent172884b
2 files changed+133−2
libraries/Basics.elm−2 libraries/String.elm+133
libraries/Basics.elm−2
@@ -49,8 +49,6 @@ which happen to be radians.
4949
5050import Native.Basics
5151
52−type String = [Char]
53−
5452{-| Convert radians to standard Elm angles (radians). -}
5553radians : Float -> Float
5654radians t = t
libraries/String.elmnew file+133
@@ -0,0 +1,133 @@
1+module String where
2+{-| A built-in representation of String for effecient string manipulation.
3+-}
4+
5+import Native.String as Native
6+import Maybe
7+
8+data String = String
9+
10+{-|
11+-}
12+isEmpty : String
13+isEmpty = Native.isEmpty
14+
15+{-|
16+-}
17+cons : Char -> String -> String
18+cons = Native.cons
19+
20+{-|
21+-}
22+uncons : String -> Maybe (Char, String)
23+uncons = Native.uncons
24+
25+{-|
26+-}
27+map : (Char -> Char) -> String -> String
28+map = Native.map
29+
30+{-|
31+-}
32+filter : (Char -> Bool) -> String -> String
33+filter = Native.filter
34+
35+{-|
36+-}
37+reverse : String -> String
38+reverse = Native.reverse
39+
40+{-|
41+-}
42+foldl : (Char -> b -> b) -> b -> String -> b
43+foldl = Native.foldl
44+
45+{-|
46+-}
47+foldr : (Char -> b -> b) -> b -> String -> b
48+foldr = Native.foldr
49+
50+{-|
51+-}
52+split : String -> String -> [String]
53+split = Native.split
54+
55+{-|
56+-}
57+join : String -> [String] -> String
58+join = Native.join
59+
60+{-|
61+-}
62+repeat : Int -> String -> String
63+repeat = Native.repeat
64+
65+{-|
66+-}
67+center : Int -> Char -> String -> String
68+center = Native.center
69+
70+{-|
71+-}
72+justifyLeft : Int -> Char -> String -> String
73+justifyLeft = Native.justifyLeft
74+
75+{-|
76+-}
77+justifyRight : Int -> Char -> String -> String
78+justifyRight = Native.justifyRight
79+
80+{-|
81+-}
82+trim : String -> String
83+trim = Native.trim
84+
85+{-|
86+-}
87+trimLeft : String -> String
88+trimLeft = Native.trimLeft
89+
90+{-|
91+-}
92+trimRight : String -> String
93+trimRight = Native.trimRight
94+
95+{-|
96+-}
97+words : String -> [String]
98+words = Native.words
99+
100+{-|
101+-}
102+unwords : [String] -> String
103+unwords = Native.unwords
104+
105+{-|
106+-}
107+lines : String -> [String]
108+lines = Native.lines
109+
110+{-|
111+-}
112+unlines : [String] -> String
113+unlines = Native.unlines
114+
115+{-|
116+-}
117+toUpper : String -> String
118+toUpper = Native.toUpper
119+
120+{-|
121+-}
122+toLower : String -> String
123+toLower = Native.toLower
124+
125+{-|
126+-}
127+any : (Char -> Bool) -> String -> Bool
128+any = Native.any
129+
130+{-|
131+-}
132+all : (Char -> Bool) -> String -> Bool
133+all = Native.all