diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 81104c4..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" - }, - "extends": "eslint:recommended", - "rules": { - "strict": [2, "global"], - "block-scoped-var": 2, - "consistent-return": 2, - "eqeqeq": [2, "smart"], - "guard-for-in": 2, - "no-caller": 2, - "no-extend-native": 2, - "no-loop-func": 2, - "no-new": 2, - "no-param-reassign": 2, - "no-return-assign": 2, - "no-unused-expressions": 2, - "no-use-before-define": 2, - "radix": [2, "always"], - "indent": [2, 2, { "SwitchCase": 1 }], - "quotes": [2, "double"], - "semi": [2, "always"] - } -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c69237a..a1c4227 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,30 +6,18 @@ on: pull_request: branches: [master] +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - uses: purescript-contrib/setup-purescript@main - with: - purescript: "unstable" - - - uses: actions/setup-node@v2 + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 with: - node-version: "14.x" - - - name: Install dependencies - run: | - npm install -g bower - npm install - bower install --production - - - name: Build source - run: npm run-script build - - - name: Run tests - run: | - bower install - npm run-script test --if-present + node-version: "24" + - run: npm install + - run: npm run build + - run: npm run lint + - run: npm run format:check diff --git a/.gitignore b/.gitignore index b846b63..7ddb3b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ /.* !/.gitignore -!/.eslintrc.json +!/.tidyrc.json +!/.oxfmtrc.json !/.github/ /bower_components/ /node_modules/ /output/ -package-lock.json +/package-lock.json +/spago.lock diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000..757fd64 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,3 @@ +{ + "trailingComma": "es5" +} diff --git a/.tidyrc.json b/.tidyrc.json new file mode 100644 index 0000000..9e39cf1 --- /dev/null +++ b/.tidyrc.json @@ -0,0 +1,10 @@ +{ + "importSort": "ide", + "importWrap": "source", + "indent": 2, + "operatorsFile": null, + "ribbon": 1, + "typeArrowPlacement": "first", + "unicode": "never", + "width": null +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7427a2e..fdc0951 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [Unreleased](https://github.com/purescript/purescript-effect/compare/v4.0.1...HEAD) Breaking changes: @@ -12,9 +12,22 @@ Bugfixes: Other improvements: +## [v4.0.1](https://github.com/purescript/purescript-effect/releases/tag/v4.0.1) - 2026-10-17 + +Breaking changes: + +New features: + +Bugfixes: + +Other improvements: + +- Migrate from Bower/Pulp to Spago and update CI and formatting/linting tools (#33 by @thomashoneyman) + ## [v4.0.0](https://github.com/purescript/purescript-effect/releases/tag/v4.0.0) - 2022-04-27 Breaking changes: + - Migrate FFI to ES modules (#29 by @kl0tl and @JordanMartinez) New features: @@ -26,18 +39,21 @@ Other improvements: ## [v3.0.0](https://github.com/purescript/purescript-effect/releases/tag/v3.0.0) - 2021-02-26 Breaking changes: - - Added support for PureScript 0.14 and dropped support for all previous versions (#21) + +- Added support for PureScript 0.14 and dropped support for all previous versions (#21) New features: -- Added roles declarations to allow safe coercions (#20) + +- Added roles declarations to allow safe coercions (#20) - Added monoid instances for uncurried `EffectFn`s (#13) Bugfixes: Other improvements: - - Migrated CI to GitHub Actions and updated installation instructions to use Spago (#22) - - Added a CHANGELOG.md file and pull request template (#25, #26) - - Removed `return {}` from FFI functions for a small performance boost (#18) + +- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#22) +- Added a CHANGELOG.md file and pull request template (#25, #26) +- Removed `return {}` from FFI functions for a small performance boost (#18) ## [v2.0.1](https://github.com/purescript/purescript-effect/releases/tag/v2.0.1) - 2019-01-26 @@ -52,6 +68,3 @@ Updated for PureScript 0.12 - Added `Monoid` and `Semigroup` instances (@i-am-tom) ## [v1.0.0](https://github.com/purescript/purescript-effect/releases/tag/v1.0.0) - 2018-04-12 - - - diff --git a/README.md b/README.md index 14c9d33..7752565 100644 --- a/README.md +++ b/README.md @@ -158,11 +158,9 @@ var printRandom = function __do() { whereas a more naive compiler might, for instance, produce: ```javascript -var printRandom = Control_Bind.bind(Effect.bindEffect)(Effect_Random.random)( - function ($0) { - return Effect_Console.log(Data_Show.show(Data_Show.showNumber)($0)); - } -); +var printRandom = Control_Bind.bind(Effect.bindEffect)(Effect_Random.random)(function ($0) { + return Effect_Console.log(Data_Show.show(Data_Show.showNumber)($0)); +}); ``` While this is a small improvement, the benefit is greater when using diff --git a/bower.json b/bower.json deleted file mode 100644 index 3b520e6..0000000 --- a/bower.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "purescript-effect", - "homepage": "https://github.com/purescript/purescript-effect", - "license": "BSD-3-Clause", - "repository": { - "type": "git", - "url": "https://github.com/purescript/purescript-effect.git" - }, - "ignore": [ - "**/.*", - "bower_components", - "node_modules", - "output", - "test", - "bower.json", - "package.json" - ], - "dependencies": { - "purescript-prelude": "^6.0.0" - } -} diff --git a/package.json b/package.json index 4ea39f9..8229f19 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,22 @@ { "private": true, + "homepage": "https://github.com/purescript/purescript-effect", + "license": "BSD-3-Clause", + "repository": { + "type": "git", + "url": "https://github.com/purescript/purescript-effect.git" + }, "scripts": { - "clean": "rimraf output && rimraf .pulp-cache", - "build": "eslint src && pulp build -- --censor-lib --strict" + "build": "spago build", + "lint": "oxlint --deny-warnings src", + "format": "purs-tidy format-in-place src && oxfmt --write .", + "format:check": "purs-tidy check src && oxfmt --check ." }, "devDependencies": { - "eslint": "^7.15.0", - "pulp": "16.0.0-0", - "purescript-psa": "^0.8.2", - "rimraf": "^3.0.2" + "oxfmt": "^0.73.0", + "oxlint": "^1.88.0", + "purescript": "^0.15.16", + "purs-tidy": "^0.11.1", + "spago": "^1.0.5" } } diff --git a/spago.yaml b/spago.yaml new file mode 100644 index 0000000..1f1bf21 --- /dev/null +++ b/spago.yaml @@ -0,0 +1,15 @@ +package: + name: effect + description: The Effect monad, for handling native side effects + build: + strict: true + pedanticPackages: true + publish: + version: 4.0.1 + license: BSD-3-Clause + location: + githubOwner: purescript + githubRepo: purescript-effect + dependencies: + - prelude: ">=6.0.0 <7.0.0" +workspace: {} diff --git a/src/Effect.purs b/src/Effect.purs index 32ea342..c3704ad 100644 --- a/src/Effect.purs +++ b/src/Effect.purs @@ -3,7 +3,10 @@ -- | computations, while at the same time generating efficient JavaScript. module Effect ( Effect - , untilE, whileE, forE, foreachE + , untilE + , whileE + , forE + , foreachE ) where import Prelude diff --git a/src/Effect/Uncurried.js b/src/Effect/Uncurried.js index 09d4933..565df3f 100644 --- a/src/Effect/Uncurried.js +++ b/src/Effect/Uncurried.js @@ -1,75 +1,75 @@ export const mkEffectFn1 = function mkEffectFn1(fn) { - return function(x) { + return function (x) { return fn(x)(); }; }; export const mkEffectFn2 = function mkEffectFn2(fn) { - return function(a, b) { + return function (a, b) { return fn(a)(b)(); }; }; export const mkEffectFn3 = function mkEffectFn3(fn) { - return function(a, b, c) { + return function (a, b, c) { return fn(a)(b)(c)(); }; }; export const mkEffectFn4 = function mkEffectFn4(fn) { - return function(a, b, c, d) { + return function (a, b, c, d) { return fn(a)(b)(c)(d)(); }; }; export const mkEffectFn5 = function mkEffectFn5(fn) { - return function(a, b, c, d, e) { + return function (a, b, c, d, e) { return fn(a)(b)(c)(d)(e)(); }; }; export const mkEffectFn6 = function mkEffectFn6(fn) { - return function(a, b, c, d, e, f) { + return function (a, b, c, d, e, f) { return fn(a)(b)(c)(d)(e)(f)(); }; }; export const mkEffectFn7 = function mkEffectFn7(fn) { - return function(a, b, c, d, e, f, g) { + return function (a, b, c, d, e, f, g) { return fn(a)(b)(c)(d)(e)(f)(g)(); }; }; export const mkEffectFn8 = function mkEffectFn8(fn) { - return function(a, b, c, d, e, f, g, h) { + return function (a, b, c, d, e, f, g, h) { return fn(a)(b)(c)(d)(e)(f)(g)(h)(); }; }; export const mkEffectFn9 = function mkEffectFn9(fn) { - return function(a, b, c, d, e, f, g, h, i) { + return function (a, b, c, d, e, f, g, h, i) { return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(); }; }; export const mkEffectFn10 = function mkEffectFn10(fn) { - return function(a, b, c, d, e, f, g, h, i, j) { + return function (a, b, c, d, e, f, g, h, i, j) { return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(); }; }; export const runEffectFn1 = function runEffectFn1(fn) { - return function(a) { - return function() { + return function (a) { + return function () { return fn(a); }; }; }; export const runEffectFn2 = function runEffectFn2(fn) { - return function(a) { - return function(b) { - return function() { + return function (a) { + return function (b) { + return function () { return fn(a, b); }; }; @@ -77,10 +77,10 @@ export const runEffectFn2 = function runEffectFn2(fn) { }; export const runEffectFn3 = function runEffectFn3(fn) { - return function(a) { - return function(b) { - return function(c) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function () { return fn(a, b, c); }; }; @@ -89,11 +89,11 @@ export const runEffectFn3 = function runEffectFn3(fn) { }; export const runEffectFn4 = function runEffectFn4(fn) { - return function(a) { - return function(b) { - return function(c) { - return function(d) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return function () { return fn(a, b, c, d); }; }; @@ -103,12 +103,12 @@ export const runEffectFn4 = function runEffectFn4(fn) { }; export const runEffectFn5 = function runEffectFn5(fn) { - return function(a) { - return function(b) { - return function(c) { - return function(d) { - return function(e) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return function (e) { + return function () { return fn(a, b, c, d, e); }; }; @@ -119,13 +119,13 @@ export const runEffectFn5 = function runEffectFn5(fn) { }; export const runEffectFn6 = function runEffectFn6(fn) { - return function(a) { - return function(b) { - return function(c) { - return function(d) { - return function(e) { - return function(f) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return function (e) { + return function (f) { + return function () { return fn(a, b, c, d, e, f); }; }; @@ -137,14 +137,14 @@ export const runEffectFn6 = function runEffectFn6(fn) { }; export const runEffectFn7 = function runEffectFn7(fn) { - return function(a) { - return function(b) { - return function(c) { - return function(d) { - return function(e) { - return function(f) { - return function(g) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return function (e) { + return function (f) { + return function (g) { + return function () { return fn(a, b, c, d, e, f, g); }; }; @@ -157,15 +157,15 @@ export const runEffectFn7 = function runEffectFn7(fn) { }; export const runEffectFn8 = function runEffectFn8(fn) { - return function(a) { - return function(b) { - return function(c) { - return function(d) { - return function(e) { - return function(f) { - return function(g) { - return function(h) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return function (e) { + return function (f) { + return function (g) { + return function (h) { + return function () { return fn(a, b, c, d, e, f, g, h); }; }; @@ -179,16 +179,16 @@ export const runEffectFn8 = function runEffectFn8(fn) { }; export const runEffectFn9 = function runEffectFn9(fn) { - return function(a) { - return function(b) { - return function(c) { - return function(d) { - return function(e) { - return function(f) { - return function(g) { - return function(h) { - return function(i) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return function (e) { + return function (f) { + return function (g) { + return function (h) { + return function (i) { + return function () { return fn(a, b, c, d, e, f, g, h, i); }; }; @@ -203,17 +203,17 @@ export const runEffectFn9 = function runEffectFn9(fn) { }; export const runEffectFn10 = function runEffectFn10(fn) { - return function(a) { - return function(b) { - return function(c) { - return function(d) { - return function(e) { - return function(f) { - return function(g) { - return function(h) { - return function(i) { - return function(j) { - return function() { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return function (e) { + return function (f) { + return function (g) { + return function (h) { + return function (i) { + return function (j) { + return function () { return fn(a, b, c, d, e, f, g, h, i, j); }; }; diff --git a/src/Effect/Uncurried.purs b/src/Effect/Uncurried.purs index 7ed42e8..61ad98a 100644 --- a/src/Effect/Uncurried.purs +++ b/src/Effect/Uncurried.purs @@ -175,47 +175,160 @@ foreign import data EffectFn10 :: Type -> Type -> Type -> Type -> Type -> Type - type role EffectFn10 representational representational representational representational representational representational representational representational representational representational representational -foreign import mkEffectFn1 :: forall a r. - (a -> Effect r) -> EffectFn1 a r -foreign import mkEffectFn2 :: forall a b r. - (a -> b -> Effect r) -> EffectFn2 a b r -foreign import mkEffectFn3 :: forall a b c r. - (a -> b -> c -> Effect r) -> EffectFn3 a b c r -foreign import mkEffectFn4 :: forall a b c d r. - (a -> b -> c -> d -> Effect r) -> EffectFn4 a b c d r -foreign import mkEffectFn5 :: forall a b c d e r. - (a -> b -> c -> d -> e -> Effect r) -> EffectFn5 a b c d e r -foreign import mkEffectFn6 :: forall a b c d e f r. - (a -> b -> c -> d -> e -> f -> Effect r) -> EffectFn6 a b c d e f r -foreign import mkEffectFn7 :: forall a b c d e f g r. - (a -> b -> c -> d -> e -> f -> g -> Effect r) -> EffectFn7 a b c d e f g r -foreign import mkEffectFn8 :: forall a b c d e f g h r. - (a -> b -> c -> d -> e -> f -> g -> h -> Effect r) -> EffectFn8 a b c d e f g h r -foreign import mkEffectFn9 :: forall a b c d e f g h i r. - (a -> b -> c -> d -> e -> f -> g -> h -> i -> Effect r) -> EffectFn9 a b c d e f g h i r -foreign import mkEffectFn10 :: forall a b c d e f g h i j r. - (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> Effect r) -> EffectFn10 a b c d e f g h i j r - -foreign import runEffectFn1 :: forall a r. - EffectFn1 a r -> a -> Effect r -foreign import runEffectFn2 :: forall a b r. - EffectFn2 a b r -> a -> b -> Effect r -foreign import runEffectFn3 :: forall a b c r. - EffectFn3 a b c r -> a -> b -> c -> Effect r -foreign import runEffectFn4 :: forall a b c d r. - EffectFn4 a b c d r -> a -> b -> c -> d -> Effect r -foreign import runEffectFn5 :: forall a b c d e r. - EffectFn5 a b c d e r -> a -> b -> c -> d -> e -> Effect r -foreign import runEffectFn6 :: forall a b c d e f r. - EffectFn6 a b c d e f r -> a -> b -> c -> d -> e -> f -> Effect r -foreign import runEffectFn7 :: forall a b c d e f g r. - EffectFn7 a b c d e f g r -> a -> b -> c -> d -> e -> f -> g -> Effect r -foreign import runEffectFn8 :: forall a b c d e f g h r. - EffectFn8 a b c d e f g h r -> a -> b -> c -> d -> e -> f -> g -> h -> Effect r -foreign import runEffectFn9 :: forall a b c d e f g h i r. - EffectFn9 a b c d e f g h i r -> a -> b -> c -> d -> e -> f -> g -> h -> i -> Effect r -foreign import runEffectFn10 :: forall a b c d e f g h i j r. - EffectFn10 a b c d e f g h i j r -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> Effect r +foreign import mkEffectFn1 + :: forall a r + . (a -> Effect r) + -> EffectFn1 a r + +foreign import mkEffectFn2 + :: forall a b r + . (a -> b -> Effect r) + -> EffectFn2 a b r + +foreign import mkEffectFn3 + :: forall a b c r + . (a -> b -> c -> Effect r) + -> EffectFn3 a b c r + +foreign import mkEffectFn4 + :: forall a b c d r + . (a -> b -> c -> d -> Effect r) + -> EffectFn4 a b c d r + +foreign import mkEffectFn5 + :: forall a b c d e r + . (a -> b -> c -> d -> e -> Effect r) + -> EffectFn5 a b c d e r + +foreign import mkEffectFn6 + :: forall a b c d e f r + . (a -> b -> c -> d -> e -> f -> Effect r) + -> EffectFn6 a b c d e f r + +foreign import mkEffectFn7 + :: forall a b c d e f g r + . (a -> b -> c -> d -> e -> f -> g -> Effect r) + -> EffectFn7 a b c d e f g r + +foreign import mkEffectFn8 + :: forall a b c d e f g h r + . (a -> b -> c -> d -> e -> f -> g -> h -> Effect r) + -> EffectFn8 a b c d e f g h r + +foreign import mkEffectFn9 + :: forall a b c d e f g h i r + . (a -> b -> c -> d -> e -> f -> g -> h -> i -> Effect r) + -> EffectFn9 a b c d e f g h i r + +foreign import mkEffectFn10 + :: forall a b c d e f g h i j r + . (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> Effect r) + -> EffectFn10 a b c d e f g h i j r + +foreign import runEffectFn1 + :: forall a r + . EffectFn1 a r + -> a + -> Effect r + +foreign import runEffectFn2 + :: forall a b r + . EffectFn2 a b r + -> a + -> b + -> Effect r + +foreign import runEffectFn3 + :: forall a b c r + . EffectFn3 a b c r + -> a + -> b + -> c + -> Effect r + +foreign import runEffectFn4 + :: forall a b c d r + . EffectFn4 a b c d r + -> a + -> b + -> c + -> d + -> Effect r + +foreign import runEffectFn5 + :: forall a b c d e r + . EffectFn5 a b c d e r + -> a + -> b + -> c + -> d + -> e + -> Effect r + +foreign import runEffectFn6 + :: forall a b c d e f r + . EffectFn6 a b c d e f r + -> a + -> b + -> c + -> d + -> e + -> f + -> Effect r + +foreign import runEffectFn7 + :: forall a b c d e f g r + . EffectFn7 a b c d e f g r + -> a + -> b + -> c + -> d + -> e + -> f + -> g + -> Effect r + +foreign import runEffectFn8 + :: forall a b c d e f g h r + . EffectFn8 a b c d e f g h r + -> a + -> b + -> c + -> d + -> e + -> f + -> g + -> h + -> Effect r + +foreign import runEffectFn9 + :: forall a b c d e f g h i r + . EffectFn9 a b c d e f g h i r + -> a + -> b + -> c + -> d + -> e + -> f + -> g + -> h + -> i + -> Effect r + +foreign import runEffectFn10 + :: forall a b c d e f g h i j r + . EffectFn10 a b c d e f g h i j r + -> a + -> b + -> c + -> d + -> e + -> f + -> g + -> h + -> i + -> j + -> Effect r -- The reason these are written eta-expanded instead of as: -- ```