Skip to content

Commit 9d4ef0c

Browse files
committed
Merge pull request #59 from sharkdp/remove-fromChar-toString
Remove String.fromChar, Char.toString, fixes #51
2 parents 6e67dd1 + 7c45134 commit 9d4ef0c

File tree

9 files changed

+7
-39
lines changed

9 files changed

+7
-39
lines changed

docs/Data/Char.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
A 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

docs/Data/String.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ charAt :: Int -> String -> Maybe Char
1212

1313
Returns 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

docs/Data/String/Regex.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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`

src/Data/Char.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
// module Data.Char
55

6-
exports.toString = function (c) {
7-
return c;
8-
};
9-
106
exports.toCharCode = function (c) {
117
return c.charCodeAt(0);
128
};

src/Data/Char.purs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
-- | A type and functions for single characters.
22
module Data.Char
3-
( toString
4-
, fromCharCode
3+
( fromCharCode
54
, toCharCode
65
, toLower
76
, toUpper
87
) where
98

109
import 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.
1612
foreign import toCharCode :: Char -> Int
1713

src/Data/String.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ exports._charAt = function (just) {
1313
};
1414
};
1515

16+
exports.singleton = function (c) {
17+
return c;
18+
};
19+
1620
exports._charCodeAt = function (just) {
1721
return function (nothing) {
1822
return function (i) {

src/Data/String.purs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff 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.

test/Test/Data/Char.purs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import Data.Char
66
import Test.Assert (assert)
77

88
testChar = do
9-
log "toString"
10-
assert $ toString 'a' == "a"
11-
129
log "toCharCode"
1310
assert $ toCharCode 'a' == 97
1411
assert $ toCharCode '\n' == 10

test/Test/Data/String.purs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)