From 0316afb3b291f290ce8f80b19c7746ae72dfe382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Boros?= Date: Sat, 21 Mar 2015 18:41:23 +0100 Subject: [PATCH] cleanup, add instance doc --- README.md | 20 ++++++++++++-------- src/Data/Char/Char.purs | 3 +++ src/Data/String.purs | 15 ++++++++------- src/Data/String/Regex.purs | 2 +- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8052e4e..31504b7 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Constructs a character from the given Unicode numeric value. instance eqChar :: Eq Char ``` +Characters can be compared for equality with `==` and `/=`. #### `ordChar` @@ -50,6 +51,7 @@ instance eqChar :: Eq Char instance ordChar :: Ord Char ``` +Characters can be compared with `compare`, `>`, `>=`, `<` and `<=`. #### `showChar` @@ -57,6 +59,7 @@ instance ordChar :: Ord Char instance showChar :: Show Char ``` +Characters can be rendered as a string with `show`. ## Module Data.String @@ -64,7 +67,7 @@ instance showChar :: Show Char 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` @@ -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` @@ -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` @@ -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` @@ -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` diff --git a/src/Data/Char/Char.purs b/src/Data/Char/Char.purs index f9034bc..a243607 100644 --- a/src/Data/Char/Char.purs +++ b/src/Data/Char/Char.purs @@ -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 diff --git a/src/Data/String.purs b/src/Data/String.purs index 20c93fe..8b31d4d 100644 --- a/src/Data/String.purs +++ b/src/Data/String.purs @@ -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, @@ -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 @@ -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) { @@ -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) { diff --git a/src/Data/String/Regex.purs b/src/Data/String/Regex.purs index f3daf42..8a06310 100644 --- a/src/Data/String/Regex.purs +++ b/src/Data/String/Regex.purs @@ -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(..)