File tree Expand file tree Collapse file tree 9 files changed +7
-39
lines changed Expand file tree Collapse file tree 9 files changed +7
-39
lines changed Original file line number Diff line number Diff line change 2
2
3
3
A type and functions for single characters.
4
4
5
- #### ` toString `
6
-
7
- ``` purescript
8
- toString :: Char -> String
9
- ```
10
-
11
- Returns the string of length ` 1 ` containing only the given character.
12
-
13
5
#### ` toCharCode `
14
6
15
7
``` purescript
Original file line number Diff line number Diff line change @@ -12,14 +12,6 @@ charAt :: Int -> String -> Maybe Char
12
12
13
13
Returns the character at the given index, if the index is within bounds.
14
14
15
- #### ` fromChar `
16
-
17
- ``` purescript
18
- fromChar :: Char -> String
19
- ```
20
-
21
- Returns a string of length ` 1 ` containing the given character.
22
-
23
15
#### ` singleton `
24
16
25
17
``` purescript
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Wraps Javascript `RegExp` objects.
14
14
15
15
##### Instances
16
16
``` purescript
17
- instance showRegex :: Show Regex
17
+ Show Regex
18
18
```
19
19
20
20
#### ` RegexFlags `
Original file line number Diff line number Diff line change 3
3
4
4
// module Data.Char
5
5
6
- exports . toString = function ( c ) {
7
- return c ;
8
- } ;
9
-
10
6
exports . toCharCode = function ( c ) {
11
7
return c . charCodeAt ( 0 ) ;
12
8
} ;
Original file line number Diff line number Diff line change 1
1
-- | A type and functions for single characters.
2
2
module Data.Char
3
- ( toString
4
- , fromCharCode
3
+ ( fromCharCode
5
4
, toCharCode
6
5
, toLower
7
6
, toUpper
8
7
) where
9
8
10
9
import Prelude
11
10
12
- -- | Returns the string of length `1` containing only the given character.
13
- foreign import toString :: Char -> String
14
-
15
11
-- | Returns the numeric Unicode value of the character.
16
12
foreign import toCharCode :: Char -> Int
17
13
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ exports._charAt = function (just) {
13
13
} ;
14
14
} ;
15
15
16
+ exports . singleton = function ( c ) {
17
+ return c ;
18
+ } ;
19
+
16
20
exports . _charCodeAt = function ( just ) {
17
21
return function ( nothing ) {
18
22
return function ( i ) {
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ module Data.String
5
5
( charAt
6
6
, charCodeAt
7
7
, fromCharArray
8
- , fromChar
9
8
, toChar
10
9
, contains
11
10
, indexOf
@@ -49,14 +48,9 @@ foreign import _charAt :: (forall a. a -> Maybe a)
49
48
-> String
50
49
-> Maybe Char
51
50
52
- -- | Returns a string of length `1` containing the given character.
53
- fromChar :: Char -> String
54
- fromChar = C .toString
55
-
56
51
-- | Returns a string of length `1` containing the given character.
57
52
-- | Same as `fromChar`.
58
- singleton :: Char -> String
59
- singleton = fromChar
53
+ foreign import singleton :: Char -> String
60
54
61
55
-- | Returns the numeric Unicode value of the character at the given index,
62
56
-- | if the index is within bounds.
Original file line number Diff line number Diff line change @@ -6,9 +6,6 @@ import Data.Char
6
6
import Test.Assert (assert )
7
7
8
8
testChar = do
9
- log " toString"
10
- assert $ toString ' a' == " a"
11
-
12
9
log " toCharCode"
13
10
assert $ toCharCode ' a' == 97
14
11
assert $ toCharCode ' \n ' == 10
Original file line number Diff line number Diff line change @@ -15,9 +15,6 @@ testString = do
15
15
assert $ charAt 1 " ab" == Just ' b'
16
16
assert $ charAt 2 " ab" == Nothing
17
17
18
- log " fromChar"
19
- assert $ fromChar ' a' == " a"
20
-
21
18
log " singleton"
22
19
assert $ singleton ' a' == " a"
23
20
You can’t perform that action at this time.
0 commit comments