From 30120f3200cd114455abd8bafd918ccd65d2fa87 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:09 -0800 Subject: [PATCH 1/9] Migrated FFI to ES modules via 'lebab' --- src/Record/Builder.js | 20 ++++++++++---------- src/Record/Unsafe/Union.js | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Record/Builder.js b/src/Record/Builder.js index 89df61c..3527f58 100644 --- a/src/Record/Builder.js +++ b/src/Record/Builder.js @@ -1,6 +1,6 @@ "use strict"; -exports.copyRecord = function(rec) { +export function copyRecord(rec) { var copy = {}; for (var key in rec) { if ({}.hasOwnProperty.call(rec, key)) { @@ -8,34 +8,34 @@ exports.copyRecord = function(rec) { } } return copy; -}; +} -exports.unsafeInsert = function(l) { +export function unsafeInsert(l) { return function(a) { return function(rec) { rec[l] = a; return rec; }; }; -}; +} -exports.unsafeModify = function(l) { +export function unsafeModify(l) { return function (f) { return function(rec) { rec[l] = f(rec[l]); return rec; }; }; -}; +} -exports.unsafeDelete = function(l) { +export function unsafeDelete(l) { return function(rec) { delete rec[l]; return rec; }; -}; +} -exports.unsafeRename = function(l1) { +export function unsafeRename(l1) { return function (l2) { return function (rec) { rec[l2] = rec[l1]; @@ -43,4 +43,4 @@ exports.unsafeRename = function(l1) { return rec; }; }; -}; +} diff --git a/src/Record/Unsafe/Union.js b/src/Record/Unsafe/Union.js index 637d503..bf2488f 100644 --- a/src/Record/Unsafe/Union.js +++ b/src/Record/Unsafe/Union.js @@ -1,6 +1,6 @@ "use strict"; -exports.unsafeUnionFn = function(r1, r2) { +export function unsafeUnionFn(r1, r2) { var copy = {}; for (var k1 in r2) { if ({}.hasOwnProperty.call(r2, k1)) { @@ -13,4 +13,4 @@ exports.unsafeUnionFn = function(r1, r2) { } } return copy; -}; +} From 25077add0b8cb0585cc7988b865cbe530aa78954 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:09 -0800 Subject: [PATCH 2/9] Removed '"use strict";' in FFI files --- src/Record/Builder.js | 2 -- src/Record/Unsafe/Union.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/Record/Builder.js b/src/Record/Builder.js index 3527f58..bae6e96 100644 --- a/src/Record/Builder.js +++ b/src/Record/Builder.js @@ -1,5 +1,3 @@ -"use strict"; - export function copyRecord(rec) { var copy = {}; for (var key in rec) { diff --git a/src/Record/Unsafe/Union.js b/src/Record/Unsafe/Union.js index bf2488f..01efccf 100644 --- a/src/Record/Unsafe/Union.js +++ b/src/Record/Unsafe/Union.js @@ -1,5 +1,3 @@ -"use strict"; - export function unsafeUnionFn(r1, r2) { var copy = {}; for (var k1 in r2) { From d6b5e9fdb67fa3f01e3474a673697f8e69681603 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:09 -0800 Subject: [PATCH 3/9] 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 291dc1e2846c137098b7562a20c07a51a5909f27 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:21:09 -0800 Subject: [PATCH 4/9] 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 3ed6897..8382d60 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ }, "devDependencies": { "eslint": "^7.15.0", - "purescript-psa": "^0.8.0", - "pulp": "^15.0.0", + "purescript-psa": "^0.8.2", + "pulp": "16.0.0-0", "rimraf": "^3.0.2" } } From 7c1c51ec340b08457f0b87c2d9667b0b9f8ee40f Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 11 Mar 2022 14:59:25 -0800 Subject: [PATCH 5/9] Update Bower dependencies to master --- bower.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 4f90f39..28a4814 100644 --- a/bower.json +++ b/bower.json @@ -17,11 +17,11 @@ "package.json" ], "dependencies": { - "purescript-functions": "^5.0.0", - "purescript-prelude": "^5.0.0", - "purescript-unsafe-coerce": "^5.0.0" + "purescript-functions": "master", + "purescript-prelude": "master", + "purescript-unsafe-coerce": "master" }, "devDependencies": { - "purescript-assert": "^5.0.0" + "purescript-assert": "master" } } From d69fef3ff3881d47d16d55c3244e24ba06546347 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 09:26:57 -0700 Subject: [PATCH 6/9] Update .eslintrc.json to ES6 --- .eslintrc.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 39963d3..81104c4 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 ef01c6e87be2fda4b6885e554013f8d65479a685 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 09:30:45 -0700 Subject: [PATCH 7/9] Remove forall proxy workaround --- src/Record.purs | 28 ++++++++++++++-------------- src/Record/Builder.purs | 19 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Record.purs b/src/Record.purs index 3b2c583..11154ca 100644 --- a/src/Record.purs +++ b/src/Record.purs @@ -34,10 +34,10 @@ import Unsafe.Coerce (unsafeCoerce) -- | get (Proxy :: Proxy "x") :: forall r a. { x :: a | r } -> a -- | ``` get - :: forall proxy r r' l a + :: forall r r' l a . IsSymbol l => Cons l a r' r - => proxy l + => Proxy l -> Record r -> a get l r = unsafeGet (reflectSymbol l) r @@ -52,11 +52,11 @@ get l r = unsafeGet (reflectSymbol l) r -- | :: forall r a b. a -> { x :: b | r } -> { x :: a | r } -- | ``` set - :: forall proxy r1 r2 r l a b + :: forall r1 r2 r l a b . IsSymbol l => Cons l a r r1 => Cons l b r r2 - => proxy l + => Proxy l -> b -> Record r1 -> Record r2 @@ -72,11 +72,11 @@ set l b r = unsafeSet (reflectSymbol l) b r -- | :: forall r a b. (a -> b) -> { x :: a | r } -> { x :: b | r } -- | ``` modify - :: forall proxy r1 r2 r l a b + :: forall r1 r2 r l a b . IsSymbol l => Cons l a r r1 => Cons l b r r2 - => proxy l + => Proxy l -> (a -> b) -> Record r1 -> Record r2 @@ -92,11 +92,11 @@ modify l f r = set l (f (get l r)) r -- | :: forall r a. Lacks "x" r => a -> { | r } -> { x :: a | r } -- | ``` insert - :: forall proxy r1 r2 l a + :: forall r1 r2 l a . IsSymbol l => Lacks l r1 => Cons l a r1 r2 - => proxy l + => Proxy l -> a -> Record r1 -> Record r2 @@ -115,11 +115,11 @@ insert l a r = unsafeSet (reflectSymbol l) a r -- | :: forall r a. Lacks "x" r => { x :: a | r } -> { | r } -- | ``` delete - :: forall proxy r1 r2 l a + :: forall r1 r2 l a . IsSymbol l => Lacks l r1 => Cons l a r1 r2 - => proxy l + => Proxy l -> Record r2 -> Record r1 delete l r = unsafeDelete (reflectSymbol l) r @@ -136,15 +136,15 @@ delete l r = unsafeDelete (reflectSymbol l) r -- | rename (Proxy :: Proxy "x") (Proxy :: Proxy "y") -- | :: forall a r. Lacks "x" r => Lacks "y" r => { x :: a | r} -> { y :: a | r} -- | ``` -rename :: forall proxy prev next ty input inter output +rename :: forall prev next ty input inter output . IsSymbol prev => IsSymbol next => Cons prev ty inter input => Lacks prev inter => Cons next ty inter output => Lacks next inter - => proxy prev - -> proxy next + => Proxy prev + -> Proxy next -> Record input -> Record output rename prev next record = @@ -224,7 +224,7 @@ equal equal a b = equalFields (Proxy :: Proxy rs) a b class EqualFields (rs :: RowList Type) (row :: Row Type) | rs -> row where - equalFields :: forall rlproxy. rlproxy rs -> Record row -> Record row -> Boolean + equalFields :: Proxy rs -> Record row -> Record row -> Boolean instance equalFieldsCons :: diff --git a/src/Record/Builder.purs b/src/Record/Builder.purs index a3bea60..acc204f 100644 --- a/src/Record/Builder.purs +++ b/src/Record/Builder.purs @@ -20,6 +20,7 @@ import Data.Function.Uncurried (runFn2) import Data.Symbol (class IsSymbol, reflectSymbol) import Prim.Row as Row import Record.Unsafe.Union (unsafeUnionFn) +import Type.Proxy (Proxy) import Unsafe.Coerce (unsafeCoerce) foreign import copyRecord :: forall r1. Record r1 -> Record r1 @@ -61,46 +62,46 @@ derive newtype instance categoryBuilder :: Category Builder -- | Build by inserting a new field. insert - :: forall proxy l a r1 r2 + :: forall l a r1 r2 . Row.Cons l a r1 r2 => Row.Lacks l r1 => IsSymbol l - => proxy l + => Proxy l -> a -> Builder (Record r1) (Record r2) insert l a = Builder \r1 -> unsafeInsert (reflectSymbol l) a r1 -- | Build by modifying an existing field. modify - :: forall proxy l a b r r1 r2 + :: forall l a b r r1 r2 . Row.Cons l a r r1 => Row.Cons l b r r2 => IsSymbol l - => proxy l + => Proxy l -> (a -> b) -> Builder (Record r1) (Record r2) modify l f = Builder \r1 -> unsafeModify (reflectSymbol l) f r1 -- | Build by deleting an existing field. delete - :: forall proxy l a r1 r2 + :: forall l a r1 r2 . IsSymbol l => Row.Lacks l r1 => Row.Cons l a r1 r2 - => proxy l + => Proxy l -> Builder (Record r2) (Record r1) delete l = Builder \r2 -> unsafeDelete (reflectSymbol l) r2 -- | Build by renaming an existing field. -rename :: forall proxy l1 l2 a r1 r2 r3 +rename :: forall l1 l2 a r1 r2 r3 . IsSymbol l1 => IsSymbol l2 => Row.Cons l1 a r2 r1 => Row.Lacks l1 r2 => Row.Cons l2 a r2 r3 => Row.Lacks l2 r2 - => proxy l1 - -> proxy l2 + => Proxy l1 + -> Proxy l2 -> Builder (Record r1) (Record r3) rename l1 l2 = Builder \r1 -> unsafeRename (reflectSymbol l1) (reflectSymbol l2) r1 From e2dbb159e5a4b03657c0b6871203cae26b023e5d Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Mon, 14 Mar 2022 09:31:56 -0700 Subject: [PATCH 8/9] Added changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf067cc..52d82d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: +- Migrate FFI to ES modules (#81 by @kl0tl and @JordanMartinez) +- Removed `forall proxy` workaround (#81 by @JordanMartinez New features: From cbd40f078bc1539cf9ad7cdac164ee91121b03f8 Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Mon, 14 Mar 2022 09:34:44 -0700 Subject: [PATCH 9/9] Update CHANGELOG.md Co-authored-by: Thomas Honeyman --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52d82d9..eeae3fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: - Migrate FFI to ES modules (#81 by @kl0tl and @JordanMartinez) -- Removed `forall proxy` workaround (#81 by @JordanMartinez +- Replaced polymorphic proxies with monomorphic `Proxy` (#81 by @JordanMartinez) New features: