Skip to content

Commit ba08c0f

Browse files
committed
Updates for RC
1 parent dc3e3de commit ba08c0f

19 files changed

+300
-219
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/.*
22
!/.gitignore
3+
!/.jscsrc
4+
!/.jshintrc
35
!/.travis.yml
46
/bower_components/
57
/node_modules/
68
/output/
7-
/tmp/

.jscsrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"preset": "grunt",
3+
"disallowSpacesInAnonymousFunctionExpression": null,
4+
"requireSpacesInAnonymousFunctionExpression": {
5+
"beforeOpeningRoundBrace": true,
6+
"beforeOpeningCurlyBrace": true
7+
},
8+
"disallowSpacesInsideObjectBrackets": null,
9+
"requireSpacesInsideObjectBrackets": "all",
10+
"validateQuoteMarks": "\"",
11+
"requireCurlyBraces": null
12+
}

.jshintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"bitwise": true,
3+
"eqeqeq": true,
4+
"forin": true,
5+
"freeze": true,
6+
"funcscope": true,
7+
"futurehostile": true,
8+
"globalstrict": true,
9+
"latedef": true,
10+
"maxparams": 1,
11+
"noarg": true,
12+
"nocomma": true,
13+
"nonew": true,
14+
"notypeof": true,
15+
"singleGroups": true,
16+
"undef": true,
17+
"unused": true,
18+
"eqnull": true
19+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/purescript/purescript-strings.svg?branch=master)](https://travis-ci.org/purescript/purescript-strings)
44

5-
String utility functions, Char type, regular expressions.
5+
String and char utility functions, regular expressions.
66

77
## Installation
88

bower.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "purescript-strings",
33
"homepage": "https://github.com/purescript/purescript-strings",
4-
"description": "String utility functions, Char type, regular expressions.",
4+
"description": "String and char utility functions, regular expressions.",
55
"keywords": [
66
"purescript"
77
],
@@ -16,7 +16,6 @@
1616
"package.json"
1717
],
1818
"dependencies": {
19-
"purescript-functions": "~0.1.0",
20-
"purescript-maybe": "~0.3.0"
19+
"purescript-maybe": "^0.3.0"
2120
}
2221
}

docs/Data.Char.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
# Module Documentation
2-
31
## Module Data.Char
42

5-
63
A type and functions for single characters.
74

8-
#### `Char`
9-
10-
``` purescript
11-
newtype Char
12-
```
13-
14-
A unicode character.
15-
165
#### `toString`
176

187
``` purescript
@@ -37,37 +26,4 @@ fromCharCode :: Int -> Char
3726

3827
Constructs a character from the given Unicode numeric value.
3928

40-
#### `eqChar`
41-
42-
``` purescript
43-
instance eqChar :: Eq Char
44-
```
45-
46-
Characters can be compared for equality with `==` and `/=`.
47-
48-
#### `ordChar`
49-
50-
``` purescript
51-
instance ordChar :: Ord Char
52-
```
53-
54-
Characters can be compared with `compare`, `>`, `>=`, `<` and `<=`.
55-
56-
#### `boundedChar`
57-
58-
``` purescript
59-
instance boundedChar :: Bounded Char
60-
```
61-
62-
Characters fall within the Unicode range.
63-
64-
#### `showChar`
65-
66-
``` purescript
67-
instance showChar :: Show Char
68-
```
69-
70-
Characters can be rendered as a string with `show`.
71-
72-
7329

docs/Data.String.Regex.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# Module Documentation
2-
31
## Module Data.String.Regex
42

5-
63
Wraps Javascript's `RegExp` object that enables matching strings with
74
patternes defined by regular expressions.
85
For details of the underlying implementation, see [RegExp Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp).
@@ -15,17 +12,15 @@ data Regex :: *
1512

1613
Wraps Javascript `RegExp` objects.
1714

18-
#### `showRegex`
19-
15+
##### Instances
2016
``` purescript
2117
instance showRegex :: Show Regex
2218
```
2319

24-
2520
#### `RegexFlags`
2621

2722
``` purescript
28-
type RegexFlags = { unicode :: Boolean, sticky :: Boolean, multiline :: Boolean, ignoreCase :: Boolean, global :: Boolean }
23+
type RegexFlags = { global :: Boolean, ignoreCase :: Boolean, multiline :: Boolean, sticky :: Boolean, unicode :: Boolean }
2924
```
3025

3126
Flags that control matching.
@@ -89,7 +84,7 @@ Returns `true` if the `Regex` matches the string.
8984
#### `match`
9085

9186
``` purescript
92-
match :: Regex -> String -> Maybe [Maybe String]
87+
match :: Regex -> String -> Maybe (Array (Maybe String))
9388
```
9489

9590
Matches the string against the `Regex` and returns an array of matches
@@ -110,7 +105,7 @@ See [reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc
110105
#### `replace'`
111106

112107
``` purescript
113-
replace' :: Regex -> (String -> [String] -> String) -> String -> String
108+
replace' :: Regex -> (String -> Array String -> String) -> String -> String
114109
```
115110

116111
Transforms occurences of the `Regex` using a function of the matched
@@ -129,10 +124,9 @@ Returns the index of the first match of the `Regex` in the string, or
129124
#### `split`
130125

131126
``` purescript
132-
split :: Regex -> String -> [String]
127+
split :: Regex -> String -> Array String
133128
```
134129

135130
Split the string into an array of substrings along occurences of the `Regex`.
136131

137132

138-

docs/Data.String.Unsafe.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# Module Documentation
2-
31
## Module Data.String.Unsafe
42

5-
63
Unsafe string and character functions.
74

85
#### `charCodeAt`
@@ -36,4 +33,3 @@ Converts a string of length `1` to a character.
3633
**Unsafe:** throws runtime exception if length is not `1`.
3734

3835

39-

docs/Data.String.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# Module Documentation
2-
31
## Module Data.String
42

5-
63
Wraps the functions of Javascript's `String` object.
74
A String represents a sequence of characters.
85
For details of the underlying implementation, see [String Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String).
@@ -41,6 +38,12 @@ charCodeAt :: Int -> String -> Maybe Int
4138
Returns the numeric Unicode value of the character at the given index,
4239
if the index is within bounds.
4340

41+
#### `toChar`
42+
43+
``` purescript
44+
toChar :: String -> Maybe Char
45+
```
46+
4447
#### `null`
4548

4649
``` purescript
@@ -52,7 +55,7 @@ Returns `true` if the given string is empty.
5255
#### `uncons`
5356

5457
``` purescript
55-
uncons :: String -> Maybe { tail :: String, head :: Char }
58+
uncons :: String -> Maybe { head :: Char, tail :: String }
5659
```
5760

5861
Returns the first character and the rest of the string,
@@ -78,7 +81,7 @@ Returns the suffix remaining after `takeWhile`.
7881
#### `fromCharArray`
7982

8083
``` purescript
81-
fromCharArray :: [Char] -> String
84+
fromCharArray :: Array Char -> String
8285
```
8386

8487
Converts an array of characters into a string.
@@ -180,7 +183,7 @@ Returns the number of characters in the string for which the predicate holds.
180183
#### `split`
181184

182185
``` purescript
183-
split :: String -> String -> [String]
186+
split :: String -> String -> Array String
184187
```
185188

186189
Returns the substrings of the first string separated along occurences
@@ -189,7 +192,7 @@ of the second string.
189192
#### `toCharArray`
190193

191194
``` purescript
192-
toCharArray :: String -> [Char]
195+
toCharArray :: String -> Array Char
193196
```
194197

195198
Converts the string into an array of characters.
@@ -223,18 +226,10 @@ and [line terminators](http://www.ecma-international.org/ecma-262/5.1/#sec-7.3).
223226
#### `joinWith`
224227

225228
``` purescript
226-
joinWith :: String -> [String] -> String
229+
joinWith :: String -> Array String -> String
227230
```
228231

229232
Joins the strings in the array together, inserting the first argument
230233
as separator between them.
231234

232-
#### `stringMonoid`
233-
234-
``` purescript
235-
instance stringMonoid :: Monoid String
236-
```
237-
238-
239-
240235

gulpfile.js

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,63 @@
1+
/* jshint node: true */
12
"use strict";
23

34
var gulp = require("gulp");
5+
var jshint = require("gulp-jshint");
6+
var jscs = require("gulp-jscs");
47
var plumber = require("gulp-plumber");
58
var purescript = require("gulp-purescript");
6-
var jsvalidate = require("gulp-jsvalidate");
9+
var rimraf = require("rimraf");
710

8-
var paths = [
11+
var sources = [
912
"src/**/*.purs",
1013
"bower_components/purescript-*/src/**/*.purs"
1114
];
1215

13-
gulp.task("make", function() {
14-
return gulp.src(paths)
15-
.pipe(plumber())
16-
.pipe(purescript.pscMake());
16+
var foreigns = [
17+
"src/**/*.js",
18+
"bower_components/purescript-*/src/**/*.js"
19+
];
20+
21+
gulp.task("clean-docs", function (cb) {
22+
rimraf("docs", cb);
1723
});
1824

19-
gulp.task("jsvalidate", ["make"], function () {
20-
return gulp.src("output/**/*.js")
21-
.pipe(plumber())
22-
.pipe(jsvalidate());
25+
gulp.task("clean-output", function (cb) {
26+
rimraf("output", cb);
2327
});
2428

25-
var docTasks = [];
29+
gulp.task("clean", ["clean-docs", "clean-output"]);
2630

27-
var docTask = function(name) {
28-
var taskName = "docs-" + name.toLowerCase();
29-
gulp.task(taskName, function () {
30-
return gulp.src("src/" + name.replace(/\./g, "/") + ".purs")
31-
.pipe(plumber())
32-
.pipe(purescript.pscDocs())
33-
.pipe(gulp.dest("docs/" + name + ".md"));
34-
});
35-
docTasks.push(taskName);
36-
};
31+
gulp.task("lint", function() {
32+
return gulp.src("src/**/*.js")
33+
.pipe(jshint())
34+
.pipe(jshint.reporter())
35+
.pipe(jscs());
36+
});
3737

38-
["Data.Char", "Data.String", "Data.String.Regex", "Data.String.Unsafe"].forEach(docTask);
38+
gulp.task("make", ["lint"], function() {
39+
return gulp.src(sources)
40+
.pipe(plumber())
41+
.pipe(purescript.pscMake({ ffi: foreigns }));
42+
});
3943

40-
gulp.task("docs", docTasks);
44+
gulp.task("docs", ["clean-docs"], function () {
45+
return gulp.src(sources)
46+
.pipe(plumber())
47+
.pipe(purescript.pscDocs({
48+
docgen: {
49+
"Data.Char": "docs/Data.Char.md",
50+
"Data.String": "docs/Data.String.md",
51+
"Data.String.Regex": "docs/Data.String.Regex.md",
52+
"Data.String.Unsafe": "docs/Data.String.Unsafe.md"
53+
}
54+
}));
55+
});
4156

4257
gulp.task("dotpsci", function () {
43-
return gulp.src(paths)
58+
return gulp.src(sources)
4459
.pipe(plumber())
4560
.pipe(purescript.dotPsci());
4661
});
4762

48-
gulp.task("default", ["jsvalidate", "docs", "dotpsci"]);
63+
gulp.task("default", ["make", "docs", "dotpsci"]);

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
"private": true,
33
"devDependencies": {
44
"gulp": "^3.8.11",
5-
"gulp-jsvalidate": "^1.0.1",
5+
"gulp-jscs": "^1.6.0",
6+
"gulp-jshint": "^1.10.0",
67
"gulp-plumber": "^1.0.0",
7-
"gulp-purescript": "^0.3.1"
8+
"gulp-purescript": "^0.5.0-rc.1",
9+
"rimraf": "^2.3.3"
810
}
911
}

src/Data/Char.js

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

44
// module Data.Char
55

6-
exports.toString = function(c) {
6+
exports.toString = function (c) {
77
return c;
88
};
99

10-
exports.toCharCode = function(c) {
10+
exports.toCharCode = function (c) {
1111
return c.charCodeAt(0);
1212
};
1313

14-
exports.fromCharCode = function(c) {
14+
exports.fromCharCode = function (c) {
1515
return String.fromCharCode(c);
16-
};
16+
};

0 commit comments

Comments
 (0)