Skip to content

Remove String.fromChar, Char.toString, fixes #51 #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions docs/Data/Char.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

A type and functions for single characters.

#### `toString`

``` purescript
toString :: Char -> String
```

Returns the string of length `1` containing only the given character.

#### `toCharCode`

``` purescript
Expand Down
8 changes: 0 additions & 8 deletions docs/Data/String.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ charAt :: Int -> String -> Maybe Char

Returns the character at the given index, if the index is within bounds.

#### `fromChar`

``` purescript
fromChar :: Char -> String
```

Returns a string of length `1` containing the given character.

#### `singleton`

``` purescript
Expand Down
2 changes: 1 addition & 1 deletion docs/Data/String/Regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Wraps Javascript `RegExp` objects.

##### Instances
``` purescript
instance showRegex :: Show Regex
Show Regex
```

#### `RegexFlags`
Expand Down
4 changes: 0 additions & 4 deletions src/Data/Char.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

// module Data.Char

exports.toString = function (c) {
return c;
};

exports.toCharCode = function (c) {
return c.charCodeAt(0);
};
Expand Down
6 changes: 1 addition & 5 deletions src/Data/Char.purs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
-- | A type and functions for single characters.
module Data.Char
( toString
, fromCharCode
( fromCharCode
, toCharCode
, toLower
, toUpper
) where

import Prelude

-- | Returns the string of length `1` containing only the given character.
foreign import toString :: Char -> String

-- | Returns the numeric Unicode value of the character.
foreign import toCharCode :: Char -> Int

Expand Down
4 changes: 4 additions & 0 deletions src/Data/String.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ exports._charAt = function (just) {
};
};

exports.singleton = function (c) {
return c;
};

exports._charCodeAt = function (just) {
return function (nothing) {
return function (i) {
Expand Down
8 changes: 1 addition & 7 deletions src/Data/String.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Data.String
( charAt
, charCodeAt
, fromCharArray
, fromChar
, toChar
, contains
, indexOf
Expand Down Expand Up @@ -49,14 +48,9 @@ foreign import _charAt :: (forall a. a -> Maybe a)
-> String
-> Maybe Char

-- | Returns a string of length `1` containing the given character.
fromChar :: Char -> String
fromChar = C.toString

-- | Returns a string of length `1` containing the given character.
-- | Same as `fromChar`.
singleton :: Char -> String
singleton = fromChar
foreign import singleton :: Char -> String

-- | Returns the numeric Unicode value of the character at the given index,
-- | if the index is within bounds.
Expand Down
3 changes: 0 additions & 3 deletions test/Test/Data/Char.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import Data.Char
import Test.Assert (assert)

testChar = do
log "toString"
assert $ toString 'a' == "a"

log "toCharCode"
assert $ toCharCode 'a' == 97
assert $ toCharCode '\n' == 10
Expand Down
3 changes: 0 additions & 3 deletions test/Test/Data/String.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ testString = do
assert $ charAt 1 "ab" == Just 'b'
assert $ charAt 2 "ab" == Nothing

log "fromChar"
assert $ fromChar 'a' == "a"

log "singleton"
assert $ singleton 'a' == "a"

Expand Down