From c0fcafbfa2e41435b84cb61f71685c0b5ee09847 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Sat, 17 Jul 2021 20:23:43 +0200 Subject: [PATCH 01/10] Convert foreign modules to try bundling with esbuild --- src/Control/Monad/ST/Internal.js | 22 +++++++++++----------- src/Control/Monad/ST/Internal.purs | 10 ++++++++-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Control/Monad/ST/Internal.js b/src/Control/Monad/ST/Internal.js index 7745a05..34a4dd4 100644 --- a/src/Control/Monad/ST/Internal.js +++ b/src/Control/Monad/ST/Internal.js @@ -1,6 +1,6 @@ "use strict"; -exports.map_ = function (f) { +export var map_ = function (f) { return function (a) { return function () { return f(a()); @@ -8,13 +8,13 @@ exports.map_ = function (f) { }; }; -exports.pure_ = function (a) { +export var pure_ = function (a) { return function () { return a; }; }; -exports.bind_ = function (a) { +export var bind_ = function (a) { return function (f) { return function () { return f(a())(); @@ -22,11 +22,11 @@ exports.bind_ = function (a) { }; }; -exports.run = function (f) { +export var run = function (f) { return f(); }; -exports["while"] = function (f) { +export var while_ = function (f) { return function (a) { return function () { while (f()) { @@ -36,7 +36,7 @@ exports["while"] = function (f) { }; }; -exports["for"] = function (lo) { +export var for_ = function (lo) { return function (hi) { return function (f) { return function () { @@ -48,7 +48,7 @@ exports["for"] = function (lo) { }; }; -exports.foreach = function (as) { +export var foreach = function (as) { return function (f) { return function () { for (var i = 0, l = as.length; i < l; i++) { @@ -58,19 +58,19 @@ exports.foreach = function (as) { }; }; -exports.new = function (val) { +export var new = function (val) { return function () { return { value: val }; }; }; -exports.read = function (ref) { +export var read = function (ref) { return function () { return ref.value; }; }; -exports.modifyImpl = function (f) { +export var modifyImpl = function (f) { return function (ref) { return function () { var t = f(ref.value); @@ -80,7 +80,7 @@ exports.modifyImpl = function (f) { }; }; -exports.write = function (a) { +export var write = function (a) { return function (ref) { return function () { return ref.value = a; // eslint-disable-line no-return-assign diff --git a/src/Control/Monad/ST/Internal.purs b/src/Control/Monad/ST/Internal.purs index a467276..6100005 100644 --- a/src/Control/Monad/ST/Internal.purs +++ b/src/Control/Monad/ST/Internal.purs @@ -86,13 +86,19 @@ foreign import run :: forall a. (forall r. ST r a) -> a -- | `while b m` is ST computation which runs the ST computation `b`. If its -- | result is `true`, it runs the ST computation `m` and loops. If not, the -- | computation ends. -foreign import while :: forall r a. ST r Boolean -> ST r a -> ST r Unit +foreign import while_ :: forall r a. ST r Boolean -> ST r a -> ST r Unit + +while :: forall r a. ST r Boolean -> ST r a -> ST r Unit +while = while_ -- | Loop over a consecutive collection of numbers -- | -- | `ST.for lo hi f` runs the computation returned by the function `f` for each -- | of the inputs between `lo` (inclusive) and `hi` (exclusive). -foreign import for :: forall r a. Int -> Int -> (Int -> ST r a) -> ST r Unit +foreign import for_ :: forall r a. Int -> Int -> (Int -> ST r a) -> ST r Unit + +for :: forall r a. Int -> Int -> (Int -> ST r a) -> ST r Unit +for = for_ -- | Loop over an array of values. -- | From 5ba60073bf372c61705649ed0309212f4ccdd9b5 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Sun, 18 Jul 2021 17:10:19 +0200 Subject: [PATCH 02/10] fixup! Convert foreign modules to try bundling with esbuild --- src/Control/Monad/ST/Internal.js | 15 +++++++++------ src/Control/Monad/ST/Internal.purs | 10 ++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Control/Monad/ST/Internal.js b/src/Control/Monad/ST/Internal.js index 34a4dd4..aef0509 100644 --- a/src/Control/Monad/ST/Internal.js +++ b/src/Control/Monad/ST/Internal.js @@ -26,7 +26,7 @@ export var run = function (f) { return f(); }; -export var while_ = function (f) { +function whileST(f) { return function (a) { return function () { while (f()) { @@ -34,9 +34,10 @@ export var while_ = function (f) { } }; }; -}; +} +export { whileST as while }; -export var for_ = function (lo) { +function forST(lo) { return function (hi) { return function (f) { return function () { @@ -46,7 +47,8 @@ export var for_ = function (lo) { }; }; }; -}; +} +export { forST as for } export var foreach = function (as) { return function (f) { @@ -58,11 +60,12 @@ export var foreach = function (as) { }; }; -export var new = function (val) { +function newSTRef(val) { return function () { return { value: val }; }; -}; +} +export { newSTRef as new }; export var read = function (ref) { return function () { diff --git a/src/Control/Monad/ST/Internal.purs b/src/Control/Monad/ST/Internal.purs index 6100005..a467276 100644 --- a/src/Control/Monad/ST/Internal.purs +++ b/src/Control/Monad/ST/Internal.purs @@ -86,19 +86,13 @@ foreign import run :: forall a. (forall r. ST r a) -> a -- | `while b m` is ST computation which runs the ST computation `b`. If its -- | result is `true`, it runs the ST computation `m` and loops. If not, the -- | computation ends. -foreign import while_ :: forall r a. ST r Boolean -> ST r a -> ST r Unit - -while :: forall r a. ST r Boolean -> ST r a -> ST r Unit -while = while_ +foreign import while :: forall r a. ST r Boolean -> ST r a -> ST r Unit -- | Loop over a consecutive collection of numbers -- | -- | `ST.for lo hi f` runs the computation returned by the function `f` for each -- | of the inputs between `lo` (inclusive) and `hi` (exclusive). -foreign import for_ :: forall r a. Int -> Int -> (Int -> ST r a) -> ST r Unit - -for :: forall r a. Int -> Int -> (Int -> ST r a) -> ST r Unit -for = for_ +foreign import for :: forall r a. Int -> Int -> (Int -> ST r a) -> ST r Unit -- | Loop over an array of values. -- | From f6555c41357f4cc0b9929ebc7da2272d39849ca3 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:54 -0800 Subject: [PATCH 03/10] Replaced 'export var' with 'export const' --- src/Control/Monad/ST/Internal.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Control/Monad/ST/Internal.js b/src/Control/Monad/ST/Internal.js index aef0509..968248c 100644 --- a/src/Control/Monad/ST/Internal.js +++ b/src/Control/Monad/ST/Internal.js @@ -1,6 +1,6 @@ "use strict"; -export var map_ = function (f) { +export const map_ = function (f) { return function (a) { return function () { return f(a()); @@ -8,13 +8,13 @@ export var map_ = function (f) { }; }; -export var pure_ = function (a) { +export const pure_ = function (a) { return function () { return a; }; }; -export var bind_ = function (a) { +export const bind_ = function (a) { return function (f) { return function () { return f(a())(); @@ -22,7 +22,7 @@ export var bind_ = function (a) { }; }; -export var run = function (f) { +export const run = function (f) { return f(); }; @@ -50,7 +50,7 @@ function forST(lo) { } export { forST as for } -export var foreach = function (as) { +export const foreach = function (as) { return function (f) { return function () { for (var i = 0, l = as.length; i < l; i++) { @@ -67,13 +67,13 @@ function newSTRef(val) { } export { newSTRef as new }; -export var read = function (ref) { +export const read = function (ref) { return function () { return ref.value; }; }; -export var modifyImpl = function (f) { +export const modifyImpl = function (f) { return function (ref) { return function () { var t = f(ref.value); @@ -83,7 +83,7 @@ export var modifyImpl = function (f) { }; }; -export var write = function (a) { +export const write = function (a) { return function (ref) { return function () { return ref.value = a; // eslint-disable-line no-return-assign From 86fad89b5fb9e7e816264abc0c8b626ef5c13c03 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:54 -0800 Subject: [PATCH 04/10] Removed '"use strict";' in FFI files --- src/Control/Monad/ST/Internal.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Control/Monad/ST/Internal.js b/src/Control/Monad/ST/Internal.js index 968248c..bd31a44 100644 --- a/src/Control/Monad/ST/Internal.js +++ b/src/Control/Monad/ST/Internal.js @@ -1,5 +1,3 @@ -"use strict"; - export const map_ = function (f) { return function (a) { return function () { From 681f28e105cb21de450c14c690afaf11c9f26494 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:54 -0800 Subject: [PATCH 05/10] Update to CI to use 'unstable' purescript --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43d2897..b6ebf3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: - uses: actions/checkout@v2 - uses: purescript-contrib/setup-purescript@main + with: + purescript: "unstable" - uses: actions/setup-node@v1 with: From c97dd0053d8261c30c45d9f9c27847337695f241 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:54 -0800 Subject: [PATCH 06/10] Update pulp to 16.0.0-0 and psa to 0.8.2 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fd4391e..a1d6811 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ }, "devDependencies": { "eslint": "^7.15.0", - "pulp": "^15.0.0", - "purescript-psa": "^0.8.0", + "pulp": "16.0.0-0", + "purescript-psa": "^0.8.2", "rimraf": "^3.0.2" } } From efcaa95b3e9be8386121d44d1dbd801830b05494 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:59:25 -0800 Subject: [PATCH 07/10] Update Bower dependencies to master --- bower.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 24fea18..5dcc7a0 100644 --- a/bower.json +++ b/bower.json @@ -17,12 +17,12 @@ "package.json" ], "dependencies": { - "purescript-partial": "^3.0.0", - "purescript-prelude": "^5.0.0", - "purescript-tailrec": "^5.0.0", - "purescript-unsafe-coerce": "^5.0.0" + "purescript-partial": "master", + "purescript-prelude": "master", + "purescript-tailrec": "master", + "purescript-unsafe-coerce": "master" }, "devDependencies": { - "purescript-console": "^5.0.0" + "purescript-console": "master" } } From 82ab6796def693450eecca9112eb2f9981e0ad1e Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 13:49:33 -0700 Subject: [PATCH 08/10] Update .eslintrc.json to ES6 --- .eslintrc.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 84cef4f..1c6afb9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,11 +1,9 @@ { "parserOptions": { - "ecmaVersion": 5 + "ecmaVersion": 6, + "sourceType": "module" }, "extends": "eslint:recommended", - "env": { - "commonjs": true - }, "rules": { "strict": [2, "global"], "block-scoped-var": 2, From fb87f1ca4d4c607c579de4364545071666be22cf Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 13:50:25 -0700 Subject: [PATCH 09/10] Fix eslint warning --- src/Control/Monad/ST/Internal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Control/Monad/ST/Internal.js b/src/Control/Monad/ST/Internal.js index bd31a44..24d2ed8 100644 --- a/src/Control/Monad/ST/Internal.js +++ b/src/Control/Monad/ST/Internal.js @@ -46,7 +46,7 @@ function forST(lo) { }; }; } -export { forST as for } +export { forST as for }; export const foreach = function (as) { return function (f) { From 86da833946339b75a79403a29f344f5ac182f77c Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 13:51:12 -0700 Subject: [PATCH 10/10] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ca264..7e39446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: +- Migrate FFI to ES modules (#47 by @kl0tl and @JordanMartinez) New features: