Add String as a proper Elm library, remove alias to [Char]

This commit is contained in:
Evan Czaplicki 2013-10-02 15:21:00 -07:00
parent 172884b594
commit 51413f92e3
2 changed files with 133 additions and 2 deletions

View file

@ -49,8 +49,6 @@ which happen to be radians.
import Native.Basics import Native.Basics
type String = [Char]
{-| Convert radians to standard Elm angles (radians). -} {-| Convert radians to standard Elm angles (radians). -}
radians : Float -> Float radians : Float -> Float
radians t = t radians t = t

133
libraries/String.elm Normal file
View file

@ -0,0 +1,133 @@
module String where
{-| A built-in representation of String for effecient string manipulation.
-}
import Native.String as Native
import Maybe
data String = String
{-|
-}
isEmpty : String
isEmpty = Native.isEmpty
{-|
-}
cons : Char -> String -> String
cons = Native.cons
{-|
-}
uncons : String -> Maybe (Char, String)
uncons = Native.uncons
{-|
-}
map : (Char -> Char) -> String -> String
map = Native.map
{-|
-}
filter : (Char -> Bool) -> String -> String
filter = Native.filter
{-|
-}
reverse : String -> String
reverse = Native.reverse
{-|
-}
foldl : (Char -> b -> b) -> b -> String -> b
foldl = Native.foldl
{-|
-}
foldr : (Char -> b -> b) -> b -> String -> b
foldr = Native.foldr
{-|
-}
split : String -> String -> [String]
split = Native.split
{-|
-}
join : String -> [String] -> String
join = Native.join
{-|
-}
repeat : Int -> String -> String
repeat = Native.repeat
{-|
-}
center : Int -> Char -> String -> String
center = Native.center
{-|
-}
justifyLeft : Int -> Char -> String -> String
justifyLeft = Native.justifyLeft
{-|
-}
justifyRight : Int -> Char -> String -> String
justifyRight = Native.justifyRight
{-|
-}
trim : String -> String
trim = Native.trim
{-|
-}
trimLeft : String -> String
trimLeft = Native.trimLeft
{-|
-}
trimRight : String -> String
trimRight = Native.trimRight
{-|
-}
words : String -> [String]
words = Native.words
{-|
-}
unwords : [String] -> String
unwords = Native.unwords
{-|
-}
lines : String -> [String]
lines = Native.lines
{-|
-}
unlines : [String] -> String
unlines = Native.unlines
{-|
-}
toUpper : String -> String
toUpper = Native.toUpper
{-|
-}
toLower : String -> String
toLower = Native.toLower
{-|
-}
any : (Char -> Bool) -> String -> Bool
any = Native.any
{-|
-}
all : (Char -> Bool) -> String -> Bool
all = Native.all