Skip to content

Commit 834eb1b

Browse files
committed
Update for PureScript 0.15
1 parent 3e87cd1 commit 834eb1b

File tree

6 files changed

+45
-85
lines changed

6 files changed

+45
-85
lines changed

.eslintrc.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{
22
"parserOptions": {
3-
"ecmaVersion": 5
3+
"ecmaVersion": 6,
4+
"sourceType": "module"
45
},
56
"extends": "eslint:recommended",
6-
"env": {
7-
"commonjs": true
8-
},
97
"rules": {
108
"strict": [2, "global"],
119
"block-scoped-var": 2,

bower.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"package.json"
2121
],
2222
"dependencies": {
23-
"purescript-prelude": "^5.0.1",
24-
"purescript-functions": "^5.0.0",
25-
"purescript-maybe": "^5.0.0",
26-
"purescript-either": "^5.0.0",
27-
"purescript-st": "^5.0.1",
28-
"purescript-tuples": "^6.0.1",
29-
"purescript-foldable-traversable": "^5.0.1",
30-
"purescript-gen": "^3.0.0",
31-
"purescript-strings": "^5.0.0"
23+
"purescript-prelude": "^6.0.1",
24+
"purescript-functions": "^6.0.0",
25+
"purescript-maybe": "^6.0.0",
26+
"purescript-either": "^6.1.0",
27+
"purescript-st": "^6.2.0",
28+
"purescript-tuples": "^7.0.0",
29+
"purescript-foldable-traversable": "^6.0.0",
30+
"purescript-gen": "^4.0.0",
31+
"purescript-strings": "^6.0.1"
3232
}
3333
}

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
"private": true,
33
"scripts": {
44
"clean": "rimraf output && rimraf .pulp-cache",
5-
"build": "eslint src && purs-tidy check --config-require src/**/*.purs && pulp build -- --censor-lib --strict",
6-
"test": "pulp test"
5+
"build": "eslint src && purs-tidy check --config-require src/**/*.purs && pulp build -- --censor-lib --strict"
76
},
87
"devDependencies": {
9-
"eslint": "^8.7.0",
10-
"pulp": "^15.0.0",
8+
"eslint": "^8.25.0",
9+
"pulp": "^16.0.2",
1110
"purescript-psa": "^0.8.2",
12-
"purs-tidy": "^0.6.4",
11+
"purs-tidy": "^0.9.2",
1312
"rimraf": "^3.0.2"
1413
}
1514
}

src/Json/Internal.js

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
"use strict";
1+
const toString = Object.prototype.toString;
2+
const hasOwnProperty = Object.prototype.hasOwnProperty;
3+
const coerce = (x) => x;
24

3-
var toString = Object.prototype.toString;
4-
var hasOwnProperty = Object.prototype.hasOwnProperty;
5-
6-
exports._parse = function (left, right, s) {
5+
export const _parse = (left, right, s) => {
76
try {
87
return right(JSON.parse(s));
98
}
@@ -12,57 +11,36 @@ exports._parse = function (left, right, s) {
1211
}
1312
};
1413

15-
exports.print = function (j) {
16-
return JSON.stringify(j);
17-
};
14+
export const print = (j) => JSON.stringify(j);
1815

19-
exports.printIndented = function (j) {
20-
return JSON.stringify(j, null, 2);
21-
};
16+
export const printIndented = (j) => JSON.stringify(j, null, 2);
2217

23-
exports._case = function (isNull, isBool, isNum, isStr, isArr, isObj, j) {
18+
export const _case = (isNull, isBool, isNum, isStr, isArr, isObj, j) => {
2419
if (j == null) return isNull(null);
25-
var ty = typeof j;
20+
const ty = typeof j;
2621
if (ty === "boolean") return isBool(j);
2722
if (ty === "number") return isNum(j);
2823
if (ty === "string") return isStr(j);
2924
if (toString.call(j) === "[object Array]") return isArr(j);
3025
return isObj(j);
3126
};
3227

33-
exports._null = null;
28+
export const _null = null;
3429

35-
var coerce = function (x) {
36-
return x;
37-
};
30+
export const fromBoolean = coerce;
3831

39-
exports.fromBoolean = coerce;
32+
export const fromNumberWithDefault = (fallback) => (n) => isNaN(n) || !isFinite(n) ? fallback : n;
4033

41-
exports.fromNumberWithDefault = function (x) {
42-
return function (y) {
43-
if (isNaN(y) || !isFinite(y)) return x;
44-
return y;
45-
};
46-
};
34+
export const fromInt = coerce;
4735

48-
exports.fromInt = coerce;
36+
export const fromString = coerce;
4937

50-
exports.fromString = coerce;
38+
export const fromArray = coerce;
5139

52-
exports.fromArray = coerce;
40+
export const fromObject = coerce;
5341

54-
exports.fromObject = coerce;
42+
export const _entries = (tuple, obj) =>
43+
Object.entries(obj).map(([k, v]) => tuple(k)(v));
5544

56-
exports._entries = function (tuple, obj) {
57-
var result = [];
58-
for (var k in obj) {
59-
if (hasOwnProperty.call(obj, k)) {
60-
result[k] = tuple(k, obj[k]);
61-
}
62-
}
63-
return result;
64-
};
65-
66-
exports._lookup = function (nothing, just, key, obj) {
67-
return hasOwnProperty.call(obj, key) ? just(obj[key]) : nothing;
68-
};
45+
export const _lookup = (nothing, just, key, obj) =>
46+
hasOwnProperty.call(obj, key) ? just(obj[key]) : nothing;

src/Json/Object/ST.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
"use strict";
2-
3-
var hasOwnProperty = {}.hasOwnProperty;
4-
5-
exports.new = function () {
1+
export const _new = () => {
62
return {};
73
};
84

9-
exports._poke = function (k, v, obj) {
10-
return function () {
11-
obj[k] = v;
12-
};
5+
export const _poke = (k, v, obj) => () => {
6+
obj[k] = v;
137
};
148

15-
var copy = function (obj) {
16-
return function () {
17-
var r = {};
18-
for (var k in obj) {
19-
if (hasOwnProperty.call(obj, k)) {
20-
r[k] = obj[k];
21-
}
22-
}
23-
return r;
24-
};
25-
};
9+
const copy = (obj) => () => Object.assign({}, obj);
2610

27-
exports.freeze = copy;
11+
export const freeze = copy;
2812

29-
exports.thaw = copy;
13+
export const thaw = copy;
3014

31-
exports.run = function (f) {
32-
return f();
33-
};
15+
export const run = (f) => f();

src/Json/Object/ST.purs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import Json.Internal (Json, Object)
1515

1616
foreign import data STObject :: Region -> Type
1717

18-
foreign import new :: forall r. ST r (STObject r)
18+
new :: forall r. ST r (STObject r)
19+
new = _new
20+
21+
foreign import _new :: forall r. ST r (STObject r)
1922

2023
poke :: forall r. String -> Json -> STObject r -> ST r Unit
2124
poke key value obj = runFn3 _poke key value obj

0 commit comments

Comments
 (0)