Skip to content

Commit ecc6ad6

Browse files
committed
Uppercase/lowercase on Char
Added * `Data.Char.toUpperChar :: Char -> Char` * `Data.Char.toLowerChar :: Char -> Char` Removed * `Data.Char.showChar :: Show Char` - collided with `showChar` defined in the prelude?
1 parent 9968b3f commit ecc6ad6

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

docs/Data/Char.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,20 @@ fromCharCode :: Int -> Char
2626

2727
Constructs a character from the given Unicode numeric value.
2828

29+
#### `toLowerChar`
30+
31+
``` purescript
32+
toLowerChar :: Char -> Char
33+
```
34+
35+
Converts a character to lowercase.
36+
37+
#### `toUpperChar`
38+
39+
``` purescript
40+
toUpperChar :: Char -> Char
41+
```
42+
43+
Converts a character to uppercase.
44+
2945

docs/Data/String.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ of the string for which the predicate holds.
198198
split :: String -> String -> Array String
199199
```
200200

201-
Returns the substrings of the first string separated along occurences
202-
of the second string.
201+
Returns the substrings of the second string separated along occurences
202+
of the first string.
203+
* `split " " "hello world" == ["hello", "world"]`
203204

204205
#### `toCharArray`
205206

src/Data/Char.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ exports.toCharCode = function (c) {
1414
exports.fromCharCode = function (c) {
1515
return String.fromCharCode(c);
1616
};
17+
18+
exports.toLowerChar = function (c) {
19+
return c.toLowerCase();
20+
};
21+
22+
exports.toUpperChar = function (c) {
23+
return c.toUpperCase();
24+
};

src/Data/Char.purs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module Data.Char
33
( toString
44
, fromCharCode
55
, toCharCode
6+
, toLowerChar
7+
, toUpperChar
68
) where
79

810
import Prelude
@@ -16,11 +18,13 @@ foreign import toCharCode :: Char -> Int
1618
-- | Constructs a character from the given Unicode numeric value.
1719
foreign import fromCharCode :: Int -> Char
1820

21+
-- | Converts a character to lowercase.
22+
foreign import toLowerChar :: Char -> Char
23+
24+
-- | Converts a character to uppercase.
25+
foreign import toUpperChar :: Char -> Char
26+
1927
-- | Characters fall within the Unicode range.
2028
instance boundedChar :: Bounded Char where
2129
top = fromCharCode zero
2230
bottom = fromCharCode 65535
23-
24-
-- | Characters can be rendered as a string with `show`.
25-
instance showChar :: Show Char where
26-
show c = "Char " ++ show (toString c)

0 commit comments

Comments
 (0)