File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33A type and functions for single characters.
44
5- #### ` toString `
6-
7- ``` purescript
8- toString :: Char -> String
9- ```
10-
11- Returns the string of length ` 1 ` containing only the given character.
12-
135#### ` toCharCode `
146
157``` purescript
Original file line number Diff line number Diff line change @@ -12,14 +12,6 @@ charAt :: Int -> String -> Maybe Char
1212
1313Returns the character at the given index, if the index is within bounds.
1414
15- #### ` fromChar `
16-
17- ``` purescript
18- fromChar :: Char -> String
19- ```
20-
21- Returns a string of length ` 1 ` containing the given character.
22-
2315#### ` singleton `
2416
2517``` purescript
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Wraps Javascript `RegExp` objects.
1414
1515##### Instances
1616``` purescript
17- instance showRegex :: Show Regex
17+ Show Regex
1818```
1919
2020#### ` RegexFlags `
Original file line number Diff line number Diff line change 33
44// module Data.Char
55
6- exports . toString = function ( c ) {
7- return c ;
8- } ;
9-
106exports . toCharCode = function ( c ) {
117 return c . charCodeAt ( 0 ) ;
128} ;
Original file line number Diff line number Diff line change 11-- | A type and functions for single characters.
22module Data.Char
3- ( toString
4- , fromCharCode
3+ ( fromCharCode
54 , toCharCode
65 , toLower
76 , toUpper
87 ) where
98
109import Prelude
1110
12- -- | Returns the string of length `1` containing only the given character.
13- foreign import toString :: Char -> String
14-
1511-- | Returns the numeric Unicode value of the character.
1612foreign import toCharCode :: Char -> Int
1713
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ exports._charAt = function (just) {
1313 } ;
1414} ;
1515
16+ exports . singleton = function ( c ) {
17+ return c ;
18+ } ;
19+
1620exports . _charCodeAt = function ( just ) {
1721 return function ( nothing ) {
1822 return function ( i ) {
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ module Data.String
55 ( charAt
66 , charCodeAt
77 , fromCharArray
8- , fromChar
98 , toChar
109 , contains
1110 , indexOf
@@ -49,14 +48,9 @@ foreign import _charAt :: (forall a. a -> Maybe a)
4948 -> String
5049 -> Maybe Char
5150
52- -- | Returns a string of length `1` containing the given character.
53- fromChar :: Char -> String
54- fromChar = C .toString
55-
5651-- | Returns a string of length `1` containing the given character.
5752-- | Same as `fromChar`.
58- singleton :: Char -> String
59- singleton = fromChar
53+ foreign import singleton :: Char -> String
6054
6155-- | Returns the numeric Unicode value of the character at the given index,
6256-- | if the index is within bounds.
Original file line number Diff line number Diff line change @@ -6,9 +6,6 @@ import Data.Char
66import Test.Assert (assert )
77
88testChar = do
9- log " toString"
10- assert $ toString ' a' == " a"
11-
129 log " toCharCode"
1310 assert $ toCharCode ' a' == 97
1411 assert $ toCharCode ' \n ' == 10
Original file line number Diff line number Diff line change @@ -15,9 +15,6 @@ testString = do
1515 assert $ charAt 1 " ab" == Just ' b'
1616 assert $ charAt 2 " ab" == Nothing
1717
18- log " fromChar"
19- assert $ fromChar ' a' == " a"
20-
2118 log " singleton"
2219 assert $ singleton ' a' == " a"
2320
You can’t perform that action at this time.
0 commit comments