Skip to content

Commit

Permalink
Update to v0.15.0 (#158)
Browse files Browse the repository at this point in the history
* 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 <sobierajewicz.cyril@gmail.com>
  • Loading branch information
JordanMartinez and kl0tl authored Mar 15, 2022
1 parent 36493ee commit a8e757f
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 82 deletions.
6 changes: 2 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"

- uses: actions/setup-node@v1
with:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (#158 by @kl0tl and @JordanMartinez)
- Replaced polymorphic proxies with monomorphic `Proxy` (#158 by @JordanMartinez)

New features:

Expand Down
38 changes: 19 additions & 19 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
"package.json"
],
"dependencies": {
"purescript-arrays": "^6.0.0",
"purescript-control": "^5.0.0",
"purescript-either": "^5.0.0",
"purescript-enums": "^5.0.0",
"purescript-foldable-traversable": "^5.0.0",
"purescript-gen": "^3.0.0",
"purescript-integers": "^5.0.0",
"purescript-maybe": "^5.0.0",
"purescript-newtype": "^4.0.0",
"purescript-nonempty": "^6.0.0",
"purescript-partial": "^3.0.0",
"purescript-prelude": "^5.0.0",
"purescript-tailrec": "^5.0.0",
"purescript-tuples": "^6.0.0",
"purescript-unfoldable": "^5.0.0",
"purescript-unsafe-coerce": "^5.0.0"
"purescript-arrays": "master",
"purescript-control": "master",
"purescript-either": "master",
"purescript-enums": "master",
"purescript-foldable-traversable": "master",
"purescript-gen": "master",
"purescript-integers": "master",
"purescript-maybe": "master",
"purescript-newtype": "master",
"purescript-nonempty": "master",
"purescript-partial": "master",
"purescript-prelude": "master",
"purescript-tailrec": "master",
"purescript-tuples": "master",
"purescript-unfoldable": "master",
"purescript-unsafe-coerce": "master"
},
"devDependencies": {
"purescript-assert": "^5.0.0",
"purescript-console": "^5.0.0",
"purescript-minibench": "^3.0.0"
"purescript-assert": "master",
"purescript-console": "master",
"purescript-minibench": "master"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test && npm run test:run:without_codePointAt",
"test:run:without_codePointAt": "node -e \"delete String.prototype.codePointAt; require('./output/Test.Main/index.js').main();\"",
"test:run:without_codePointAt": "node -e \"delete String.prototype.codePointAt; import('./output/Test.Main/index.js').then(m => m.main());\"",
"bench:build": "purs compile 'bench/**/*.purs' 'src/**/*.purs' 'bower_components/*/src/**/*.purs'",
"bench:run": "node --expose-gc -e 'require(\"./output/Bench.Main/index.js\").main()'",
"bench": "npm run bench:build && npm run bench:run"
},
"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"
}
}
15 changes: 7 additions & 8 deletions src/Data/String/CodePoints.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"use strict";
/* global Symbol */

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

exports._unsafeCodePointAt0 = function (fallback) {
export const _unsafeCodePointAt0 = function (fallback) {
return hasCodePointAt
? function (str) { return str.codePointAt(0); }
: fallback;
};

exports._codePointAt = function (fallback) {
export const _codePointAt = function (fallback) {
return function (Just) {
return function (Nothing) {
return function (unsafeCodePointAt0) {
Expand All @@ -40,7 +39,7 @@ exports._codePointAt = function (fallback) {
};
};

exports._countPrefix = function (fallback) {
export const _countPrefix = function (fallback) {
return function (unsafeCodePointAt0) {
if (hasStringIterator) {
return function (pred) {
Expand All @@ -59,7 +58,7 @@ exports._countPrefix = function (fallback) {
};
};

exports._fromCodePointArray = function (singleton) {
export const _fromCodePointArray = function (singleton) {
return hasFromCodePoint
? function (cps) {
// Function.prototype.apply will fail for very large second parameters,
Expand All @@ -74,11 +73,11 @@ exports._fromCodePointArray = function (singleton) {
};
};

exports._singleton = function (fallback) {
export const _singleton = function (fallback) {
return hasFromCodePoint ? String.fromCodePoint : fallback;
};

exports._take = function (fallback) {
export const _take = function (fallback) {
return function (n) {
if (hasStringIterator) {
return function (str) {
Expand All @@ -96,7 +95,7 @@ exports._take = function (fallback) {
};
};

exports._toCodePointArray = function (fallback) {
export const _toCodePointArray = function (fallback) {
return function (unsafeCodePointAt0) {
if (hasArrayFrom) {
return function (str) {
Expand Down
32 changes: 15 additions & 17 deletions src/Data/String/CodeUnits.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
"use strict";

exports.fromCharArray = function (a) {
export const fromCharArray = function (a) {
return a.join("");
};

exports.toCharArray = function (s) {
export const toCharArray = function (s) {
return s.split("");
};

exports.singleton = function (c) {
export const singleton = function (c) {
return c;
};

exports._charAt = function (just) {
export const _charAt = function (just) {
return function (nothing) {
return function (i) {
return function (s) {
Expand All @@ -22,27 +20,27 @@ exports._charAt = function (just) {
};
};

exports._toChar = function (just) {
export const _toChar = function (just) {
return function (nothing) {
return function (s) {
return s.length === 1 ? just(s) : nothing;
};
};
};

exports.length = function (s) {
export const length = function (s) {
return s.length;
};

exports.countPrefix = function (p) {
export const countPrefix = function (p) {
return function (s) {
var i = 0;
while (i < s.length && p(s.charAt(i))) i++;
return i;
};
};

exports._indexOf = function (just) {
export const _indexOf = function (just) {
return function (nothing) {
return function (x) {
return function (s) {
Expand All @@ -53,7 +51,7 @@ exports._indexOf = function (just) {
};
};

exports._indexOfStartingAt = function (just) {
export const _indexOfStartingAt = function (just) {
return function (nothing) {
return function (x) {
return function (startAt) {
Expand All @@ -67,7 +65,7 @@ exports._indexOfStartingAt = function (just) {
};
};

exports._lastIndexOf = function (just) {
export const _lastIndexOf = function (just) {
return function (nothing) {
return function (x) {
return function (s) {
Expand All @@ -78,7 +76,7 @@ exports._lastIndexOf = function (just) {
};
};

exports._lastIndexOfStartingAt = function (just) {
export const _lastIndexOfStartingAt = function (just) {
return function (nothing) {
return function (x) {
return function (startAt) {
Expand All @@ -91,27 +89,27 @@ exports._lastIndexOfStartingAt = function (just) {
};
};

exports.take = function (n) {
export const take = function (n) {
return function (s) {
return s.substr(0, n);
};
};

exports.drop = function (n) {
export const drop = function (n) {
return function (s) {
return s.substring(n);
};
};

exports._slice = function (b) {
export const _slice = function (b) {
return function (e) {
return function (s) {
return s.slice(b,e);
};
};
};

exports.splitAt = function (i) {
export const splitAt = function (i) {
return function (s) {
return { before: s.substring(0, i), after: s.substring(i) };
};
Expand Down
18 changes: 8 additions & 10 deletions src/Data/String/Common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"use strict";

exports._localeCompare = function (lt) {
export const _localeCompare = function (lt) {
return function (eq) {
return function (gt) {
return function (s1) {
Expand All @@ -13,41 +11,41 @@ exports._localeCompare = function (lt) {
};
};

exports.replace = function (s1) {
export const replace = function (s1) {
return function (s2) {
return function (s3) {
return s3.replace(s1, s2);
};
};
};

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

exports.split = function (sep) {
export const split = function (sep) {
return function (s) {
return s.split(sep);
};
};

exports.toLower = function (s) {
export const toLower = function (s) {
return s.toLowerCase();
};

exports.toUpper = function (s) {
export const toUpper = function (s) {
return s.toUpperCase();
};

exports.trim = function (s) {
export const trim = function (s) {
return s.trim();
};

exports.joinWith = function (s) {
export const joinWith = function (s) {
return function (xs) {
return xs.join(s);
};
Expand Down
3 changes: 2 additions & 1 deletion src/Data/String/NonEmpty/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Data.String as String
import Data.String.Pattern (Pattern)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Prim.TypeError as TE
import Type.Proxy (Proxy)
import Unsafe.Coerce (unsafeCoerce)

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

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

0 comments on commit a8e757f

Please sign in to comment.