Skip to content

Commit a8e757f

Browse files
JordanMartinezkl0tl
andauthoredMar 15, 2022
Update to v0.15.0 (#158)
* Convert foreign modules to try bundling with esbuild * Replaced 'export var' with 'export const' * Removed '"use strict";' in FFI files * Update to CI to use 'unstable' purescript * Update pulp to 16.0.0-0 and psa to 0.8.2 * Update Bower dependencies to master * Update .eslintrc.json to ES6 * Fix compiler error due to Proxy type * Fix unused name compiler warnings * Added changelog entry * Update test script to use import Co-authored-by: Cyril Sobierajewicz <[email protected]>
1 parent 36493ee commit a8e757f

File tree

12 files changed

+76
-82
lines changed

12 files changed

+76
-82
lines changed
 

‎.eslintrc.json

+2-4
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,

‎.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
- uses: actions/checkout@v2
1414

1515
- uses: purescript-contrib/setup-purescript@main
16+
with:
17+
purescript: "unstable"
1618

1719
- uses: actions/setup-node@v1
1820
with:

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Notable changes to this project are documented in this file. The format is based
55
## [Unreleased]
66

77
Breaking changes:
8+
- Migrate FFI to ES modules (#158 by @kl0tl and @JordanMartinez)
9+
- Replaced polymorphic proxies with monomorphic `Proxy` (#158 by @JordanMartinez)
810

911
New features:
1012

‎bower.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616
"package.json"
1717
],
1818
"dependencies": {
19-
"purescript-arrays": "^6.0.0",
20-
"purescript-control": "^5.0.0",
21-
"purescript-either": "^5.0.0",
22-
"purescript-enums": "^5.0.0",
23-
"purescript-foldable-traversable": "^5.0.0",
24-
"purescript-gen": "^3.0.0",
25-
"purescript-integers": "^5.0.0",
26-
"purescript-maybe": "^5.0.0",
27-
"purescript-newtype": "^4.0.0",
28-
"purescript-nonempty": "^6.0.0",
29-
"purescript-partial": "^3.0.0",
30-
"purescript-prelude": "^5.0.0",
31-
"purescript-tailrec": "^5.0.0",
32-
"purescript-tuples": "^6.0.0",
33-
"purescript-unfoldable": "^5.0.0",
34-
"purescript-unsafe-coerce": "^5.0.0"
19+
"purescript-arrays": "master",
20+
"purescript-control": "master",
21+
"purescript-either": "master",
22+
"purescript-enums": "master",
23+
"purescript-foldable-traversable": "master",
24+
"purescript-gen": "master",
25+
"purescript-integers": "master",
26+
"purescript-maybe": "master",
27+
"purescript-newtype": "master",
28+
"purescript-nonempty": "master",
29+
"purescript-partial": "master",
30+
"purescript-prelude": "master",
31+
"purescript-tailrec": "master",
32+
"purescript-tuples": "master",
33+
"purescript-unfoldable": "master",
34+
"purescript-unsafe-coerce": "master"
3535
},
3636
"devDependencies": {
37-
"purescript-assert": "^5.0.0",
38-
"purescript-console": "^5.0.0",
39-
"purescript-minibench": "^3.0.0"
37+
"purescript-assert": "master",
38+
"purescript-console": "master",
39+
"purescript-minibench": "master"
4040
}
4141
}

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"clean": "rimraf output && rimraf .pulp-cache",
55
"build": "eslint src && pulp build -- --censor-lib --strict",
66
"test": "pulp test && npm run test:run:without_codePointAt",
7-
"test:run:without_codePointAt": "node -e \"delete String.prototype.codePointAt; require('./output/Test.Main/index.js').main();\"",
7+
"test:run:without_codePointAt": "node -e \"delete String.prototype.codePointAt; import('./output/Test.Main/index.js').then(m => m.main());\"",
88
"bench:build": "purs compile 'bench/**/*.purs' 'src/**/*.purs' 'bower_components/*/src/**/*.purs'",
99
"bench:run": "node --expose-gc -e 'require(\"./output/Bench.Main/index.js\").main()'",
1010
"bench": "npm run bench:build && npm run bench:run"
1111
},
1212
"devDependencies": {
1313
"eslint": "^7.15.0",
14-
"pulp": "^15.0.0",
15-
"purescript-psa": "^0.8.0",
14+
"pulp": "16.0.0-0",
15+
"purescript-psa": "^0.8.2",
1616
"rimraf": "^3.0.2"
1717
}
1818
}

‎src/Data/String/CodePoints.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
"use strict";
21
/* global Symbol */
32

43
var hasArrayFrom = typeof Array.from === "function";
@@ -10,13 +9,13 @@ var hasStringIterator =
109
var hasFromCodePoint = typeof String.prototype.fromCodePoint === "function";
1110
var hasCodePointAt = typeof String.prototype.codePointAt === "function";
1211

13-
exports._unsafeCodePointAt0 = function (fallback) {
12+
export const _unsafeCodePointAt0 = function (fallback) {
1413
return hasCodePointAt
1514
? function (str) { return str.codePointAt(0); }
1615
: fallback;
1716
};
1817

19-
exports._codePointAt = function (fallback) {
18+
export const _codePointAt = function (fallback) {
2019
return function (Just) {
2120
return function (Nothing) {
2221
return function (unsafeCodePointAt0) {
@@ -40,7 +39,7 @@ exports._codePointAt = function (fallback) {
4039
};
4140
};
4241

43-
exports._countPrefix = function (fallback) {
42+
export const _countPrefix = function (fallback) {
4443
return function (unsafeCodePointAt0) {
4544
if (hasStringIterator) {
4645
return function (pred) {
@@ -59,7 +58,7 @@ exports._countPrefix = function (fallback) {
5958
};
6059
};
6160

62-
exports._fromCodePointArray = function (singleton) {
61+
export const _fromCodePointArray = function (singleton) {
6362
return hasFromCodePoint
6463
? function (cps) {
6564
// Function.prototype.apply will fail for very large second parameters,
@@ -74,11 +73,11 @@ exports._fromCodePointArray = function (singleton) {
7473
};
7574
};
7675

77-
exports._singleton = function (fallback) {
76+
export const _singleton = function (fallback) {
7877
return hasFromCodePoint ? String.fromCodePoint : fallback;
7978
};
8079

81-
exports._take = function (fallback) {
80+
export const _take = function (fallback) {
8281
return function (n) {
8382
if (hasStringIterator) {
8483
return function (str) {
@@ -96,7 +95,7 @@ exports._take = function (fallback) {
9695
};
9796
};
9897

99-
exports._toCodePointArray = function (fallback) {
98+
export const _toCodePointArray = function (fallback) {
10099
return function (unsafeCodePointAt0) {
101100
if (hasArrayFrom) {
102101
return function (str) {

‎src/Data/String/CodeUnits.js

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
"use strict";
2-
3-
exports.fromCharArray = function (a) {
1+
export const fromCharArray = function (a) {
42
return a.join("");
53
};
64

7-
exports.toCharArray = function (s) {
5+
export const toCharArray = function (s) {
86
return s.split("");
97
};
108

11-
exports.singleton = function (c) {
9+
export const singleton = function (c) {
1210
return c;
1311
};
1412

15-
exports._charAt = function (just) {
13+
export const _charAt = function (just) {
1614
return function (nothing) {
1715
return function (i) {
1816
return function (s) {
@@ -22,27 +20,27 @@ exports._charAt = function (just) {
2220
};
2321
};
2422

25-
exports._toChar = function (just) {
23+
export const _toChar = function (just) {
2624
return function (nothing) {
2725
return function (s) {
2826
return s.length === 1 ? just(s) : nothing;
2927
};
3028
};
3129
};
3230

33-
exports.length = function (s) {
31+
export const length = function (s) {
3432
return s.length;
3533
};
3634

37-
exports.countPrefix = function (p) {
35+
export const countPrefix = function (p) {
3836
return function (s) {
3937
var i = 0;
4038
while (i < s.length && p(s.charAt(i))) i++;
4139
return i;
4240
};
4341
};
4442

45-
exports._indexOf = function (just) {
43+
export const _indexOf = function (just) {
4644
return function (nothing) {
4745
return function (x) {
4846
return function (s) {
@@ -53,7 +51,7 @@ exports._indexOf = function (just) {
5351
};
5452
};
5553

56-
exports._indexOfStartingAt = function (just) {
54+
export const _indexOfStartingAt = function (just) {
5755
return function (nothing) {
5856
return function (x) {
5957
return function (startAt) {
@@ -67,7 +65,7 @@ exports._indexOfStartingAt = function (just) {
6765
};
6866
};
6967

70-
exports._lastIndexOf = function (just) {
68+
export const _lastIndexOf = function (just) {
7169
return function (nothing) {
7270
return function (x) {
7371
return function (s) {
@@ -78,7 +76,7 @@ exports._lastIndexOf = function (just) {
7876
};
7977
};
8078

81-
exports._lastIndexOfStartingAt = function (just) {
79+
export const _lastIndexOfStartingAt = function (just) {
8280
return function (nothing) {
8381
return function (x) {
8482
return function (startAt) {
@@ -91,27 +89,27 @@ exports._lastIndexOfStartingAt = function (just) {
9189
};
9290
};
9391

94-
exports.take = function (n) {
92+
export const take = function (n) {
9593
return function (s) {
9694
return s.substr(0, n);
9795
};
9896
};
9997

100-
exports.drop = function (n) {
98+
export const drop = function (n) {
10199
return function (s) {
102100
return s.substring(n);
103101
};
104102
};
105103

106-
exports._slice = function (b) {
104+
export const _slice = function (b) {
107105
return function (e) {
108106
return function (s) {
109107
return s.slice(b,e);
110108
};
111109
};
112110
};
113111

114-
exports.splitAt = function (i) {
112+
export const splitAt = function (i) {
115113
return function (s) {
116114
return { before: s.substring(0, i), after: s.substring(i) };
117115
};

‎src/Data/String/Common.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"use strict";
2-
3-
exports._localeCompare = function (lt) {
1+
export const _localeCompare = function (lt) {
42
return function (eq) {
53
return function (gt) {
64
return function (s1) {
@@ -13,41 +11,41 @@ exports._localeCompare = function (lt) {
1311
};
1412
};
1513

16-
exports.replace = function (s1) {
14+
export const replace = function (s1) {
1715
return function (s2) {
1816
return function (s3) {
1917
return s3.replace(s1, s2);
2018
};
2119
};
2220
};
2321

24-
exports.replaceAll = function (s1) {
22+
export const replaceAll = function (s1) {
2523
return function (s2) {
2624
return function (s3) {
2725
return s3.replace(new RegExp(s1.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), s2); // eslint-disable-line no-useless-escape
2826
};
2927
};
3028
};
3129

32-
exports.split = function (sep) {
30+
export const split = function (sep) {
3331
return function (s) {
3432
return s.split(sep);
3533
};
3634
};
3735

38-
exports.toLower = function (s) {
36+
export const toLower = function (s) {
3937
return s.toLowerCase();
4038
};
4139

42-
exports.toUpper = function (s) {
40+
export const toUpper = function (s) {
4341
return s.toUpperCase();
4442
};
4543

46-
exports.trim = function (s) {
44+
export const trim = function (s) {
4745
return s.trim();
4846
};
4947

50-
exports.joinWith = function (s) {
48+
export const joinWith = function (s) {
5149
return function (xs) {
5250
return xs.join(s);
5351
};

‎src/Data/String/NonEmpty/Internal.purs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Data.String as String
1616
import Data.String.Pattern (Pattern)
1717
import Data.Symbol (class IsSymbol, reflectSymbol)
1818
import Prim.TypeError as TE
19+
import Type.Proxy (Proxy)
1920
import Unsafe.Coerce (unsafeCoerce)
2021

2122
-- | A string that is known not to be empty.
@@ -41,7 +42,7 @@ instance showNonEmptyString :: Show NonEmptyString where
4142
-- | something = nes (Proxy :: Proxy "something")
4243
-- | ```
4344
class MakeNonEmpty (s :: Symbol) where
44-
nes :: forall proxy. proxy s -> NonEmptyString
45+
nes :: Proxy s -> NonEmptyString
4546

4647
instance makeNonEmptyBad :: TE.Fail (TE.Text "Cannot create an NonEmptyString from an empty Symbol") => MakeNonEmpty "" where
4748
nes _ = NonEmptyString ""

‎src/Data/String/Regex.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
"use strict";
2-
3-
exports.showRegexImpl = function (r) {
1+
export const showRegexImpl = function (r) {
42
return "" + r;
53
};
64

7-
exports.regexImpl = function (left) {
5+
export const regexImpl = function (left) {
86
return function (right) {
97
return function (s1) {
108
return function (s2) {
@@ -18,11 +16,11 @@ exports.regexImpl = function (left) {
1816
};
1917
};
2018

21-
exports.source = function (r) {
19+
export const source = function (r) {
2220
return r.source;
2321
};
2422

25-
exports.flagsImpl = function (r) {
23+
export const flagsImpl = function (r) {
2624
return {
2725
multiline: r.multiline,
2826
ignoreCase: r.ignoreCase,
@@ -33,7 +31,7 @@ exports.flagsImpl = function (r) {
3331
};
3432
};
3533

36-
exports.test = function (r) {
34+
export const test = function (r) {
3735
return function (s) {
3836
var lastIndex = r.lastIndex;
3937
var result = r.test(s);
@@ -42,7 +40,7 @@ exports.test = function (r) {
4240
};
4341
};
4442

45-
exports._match = function (just) {
43+
export const _match = function (just) {
4644
return function (nothing) {
4745
return function (r) {
4846
return function (s) {
@@ -60,15 +58,15 @@ exports._match = function (just) {
6058
};
6159
};
6260

63-
exports.replace = function (r) {
61+
export const replace = function (r) {
6462
return function (s1) {
6563
return function (s2) {
6664
return s2.replace(r, s1);
6765
};
6866
};
6967
};
7068

71-
exports._replaceBy = function (just) {
69+
export const _replaceBy = function (just) {
7270
return function (nothing) {
7371
return function (r) {
7472
return function (f) {
@@ -87,7 +85,7 @@ exports._replaceBy = function (just) {
8785
};
8886
};
8987

90-
exports._search = function (just) {
88+
export const _search = function (just) {
9189
return function (nothing) {
9290
return function (r) {
9391
return function (s) {
@@ -98,7 +96,7 @@ exports._search = function (just) {
9896
};
9997
};
10098

101-
exports.split = function (r) {
99+
export const split = function (r) {
102100
return function (s) {
103101
return s.split(r);
104102
};

‎src/Data/String/Unsafe.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
"use strict";
2-
3-
exports.charAt = function (i) {
1+
export const charAt = function (i) {
42
return function (s) {
53
if (i >= 0 && i < s.length) return s.charAt(i);
64
throw new Error("Data.String.Unsafe.charAt: Invalid index.");
75
};
86
};
97

10-
exports.char = function (s) {
8+
export const char = function (s) {
119
if (s.length === 1) return s.charAt(0);
1210
throw new Error("Data.String.Unsafe.char: Expected string of length 1.");
1311
};

‎test/Test/Data/String/NonEmpty/CodeUnits.purs

+4-4
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ testNonEmptyStringCodeUnits = do
170170

171171
log "takeWhile"
172172
assertEqual
173-
{ actual: NESCU.takeWhile (\c -> true) (nes (Proxy :: Proxy "abc"))
173+
{ actual: NESCU.takeWhile (\_ -> true) (nes (Proxy :: Proxy "abc"))
174174
, expected: Just (nes (Proxy :: Proxy "abc"))
175175
}
176176
assertEqual
177-
{ actual: NESCU.takeWhile (\c -> false) (nes (Proxy :: Proxy "abc"))
177+
{ actual: NESCU.takeWhile (\_ -> false) (nes (Proxy :: Proxy "abc"))
178178
, expected: Nothing
179179
}
180180
assertEqual
@@ -192,11 +192,11 @@ testNonEmptyStringCodeUnits = do
192192

193193
log "dropWhile"
194194
assertEqual
195-
{ actual: NESCU.dropWhile (\c -> true) (nes (Proxy :: Proxy "abc"))
195+
{ actual: NESCU.dropWhile (\_ -> true) (nes (Proxy :: Proxy "abc"))
196196
, expected: Nothing
197197
}
198198
assertEqual
199-
{ actual: NESCU.dropWhile (\c -> false) (nes (Proxy :: Proxy "abc"))
199+
{ actual: NESCU.dropWhile (\_ -> false) (nes (Proxy :: Proxy "abc"))
200200
, expected: Just (nes (Proxy :: Proxy "abc"))
201201
}
202202
assertEqual

0 commit comments

Comments
 (0)
Please sign in to comment.