Skip to content

Commit

Permalink
cleanup, add instance doc
Browse files Browse the repository at this point in the history
  • Loading branch information
brainrake committed Mar 21, 2015
1 parent 2f3726a commit 0316afb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,31 @@ Constructs a character from the given Unicode numeric value.
instance eqChar :: Eq Char
```

Characters can be compared for equality with `==` and `/=`.

#### `ordChar`

``` purescript
instance ordChar :: Ord Char
```

Characters can be compared with `compare`, `>`, `>=`, `<` and `<=`.

#### `showChar`

``` purescript
instance showChar :: Show Char
```

Characters can be rendered as a string with `show`.


## Module Data.String


Wraps the functions of Javascript's `String` object.
A String represents a sequence of characters.
For examples and details of the underlying implementation, see [String Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String).
For details of the underlying implementation, see [String Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String).

#### `charAt`

Expand Down Expand Up @@ -123,8 +126,8 @@ if the string is not empty.
takeWhile :: (Char -> Boolean) -> String -> String
```

Returns the longest prefix (possibly empty) of characters that satisfy the
predicate:
Returns the longest prefix (possibly empty) of characters that satisfy
the predicate:

#### `dropWhile`

Expand Down Expand Up @@ -196,7 +199,8 @@ localeCompare :: String -> String -> Number

Locale-aware sort order comparison. Returns a negative number if the
first string occurs before the second in a sort, a positive number
if the first string occurs after the second, and 0 if they occur at the same level.
if the first string occurs after the second, and `0` if their sort order
is equal.

#### `replace`

Expand Down Expand Up @@ -269,9 +273,9 @@ Returns the argument converted to uppercase.
trim :: String -> String
```

Removes whitespace from the beginning and end of a string, where
whitespace means all the whitespace characters (space, tab, no-break
space, etc.) and all the line terminator characters (LF, CR, etc.).
Removes whitespace from the beginning and end of a string, including
[whitespace characters](http://www.ecma-international.org/ecma-262/5.1/#sec-7.2)
and [line terminators](http://www.ecma-international.org/ecma-262/5.1/#sec-7.3).

#### `joinWith`

Expand All @@ -288,7 +292,7 @@ as separator between them.

Wraps Javascript's `RegExp` object that enables matching strings with
patternes defined by regular expressions.
For examples and details of the underlying implementation, see [RegExp Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp).
For details of the underlying implementation, see [RegExp Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp).

#### `Regex`

Expand Down
3 changes: 3 additions & 0 deletions src/Data/Char/Char.purs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ module Data.Char
}
""" :: Number -> Char

-- | Characters can be compared for equality with `==` and `/=`.
instance eqChar :: Eq Char where
(==) (Char a) (Char b) = a == b

(/=) a b = not (a == b)

-- | Characters can be compared with `compare`, `>`, `>=`, `<` and `<=`.
instance ordChar :: Ord Char where
compare (Char a) (Char b) = a `compare` b

-- | Characters can be rendered as a string with `show`.
instance showChar :: Show Char where
show (Char s) = "Char " ++ show s
15 changes: 8 additions & 7 deletions src/Data/String.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- | Wraps the functions of Javascript's `String` object.
-- | A String represents a sequence of characters.
-- | For examples and details of the underlying implementation, see [String Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String).
-- | For details of the underlying implementation, see [String Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String).
module Data.String
(
charAt,
Expand Down Expand Up @@ -77,8 +77,8 @@ module Data.String
uncons s | null s = Nothing
uncons s = Just {head : U.charAt 0 s, tail : drop 1 s}

-- | Returns the longest prefix (possibly empty) of characters that satisfy the
-- | predicate:
-- | Returns the longest prefix (possibly empty) of characters that satisfy
-- | the predicate:
takeWhile :: (Char -> Boolean) -> String -> String
takeWhile p s = take (count p s) s

Expand Down Expand Up @@ -154,7 +154,8 @@ module Data.String

-- | Locale-aware sort order comparison. Returns a negative number if the
-- | first string occurs before the second in a sort, a positive number
-- | if the first string occurs after the second, and 0 if they occur at the same level.
-- | if the first string occurs after the second, and `0` if their sort order
-- | is equal.
foreign import localeCompare
"""
function localeCompare(s1) {
Expand Down Expand Up @@ -243,9 +244,9 @@ module Data.String
}
""" :: String -> String

-- | Removes whitespace from the beginning and end of a string, where
-- | whitespace means all the whitespace characters (space, tab, no-break
-- | space, etc.) and all the line terminator characters (LF, CR, etc.).
-- | Removes whitespace from the beginning and end of a string, including
-- | [whitespace characters](http://www.ecma-international.org/ecma-262/5.1/#sec-7.2)
-- | and [line terminators](http://www.ecma-international.org/ecma-262/5.1/#sec-7.3).
foreign import trim
"""
function trim(s) {
Expand Down
2 changes: 1 addition & 1 deletion src/Data/String/Regex.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- | Wraps Javascript's `RegExp` object that enables matching strings with
-- | patternes defined by regular expressions.
-- | For examples and details of the underlying implementation, see [RegExp Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp).
-- | For details of the underlying implementation, see [RegExp Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp).
module Data.String.Regex
( Regex(..)
, RegexFlags(..)
Expand Down

0 comments on commit 0316afb

Please sign in to comment.