Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

34 changes: 18 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@ 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"
node-version: "24"

- name: Install dependencies
run: |
npm install -g bower
npm install
bower install --production
run: npm install

- name: Build source
run: npm run-script build
run: npm run build

- name: Run tests
run: |
bower install
npm run-script test --if-present
run: npm test

- name: Run benchmarks
run: npm run bench

- name: Lint
run: npm run lint

- name: Check formatting
run: npm run format:check
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/.*
!/.gitignore
!/.github
!/.eslintrc.json
!/.travis.yml
package-lock.json
!/.tidyrc.json
!/.oxfmtrc.json
/package-lock.json
/spago.lock
/bower_components/
/node_modules/
/output/
3 changes: 3 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
10 changes: 10 additions & 0 deletions .tidyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"importSort": "ide",
"importWrap": "source",
"indent": 2,
"operatorsFile": null,
"ribbon": 1,
"typeArrowPlacement": "first",
"unicode": "never",
"width": null
}
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ Bugfixes:

Other improvements:

## [v7.3.1](https://github.com/purescript/purescript-arrays/releases/tag/v7.3.1) - 2026-10-17

Other improvements:

- Migrate from Bower/Pulp to Spago and update CI, linting and formatting (#247 by @thomashoneyman).

## [v7.3.0](https://github.com/purescript/purescript-arrays/releases/tag/v7.3.0) - 2023-11-03

New features:

- Add `ST.clone` (#243 by @Bgbagan)

Other improvements:
- Implements `ST.push` via a call to JavaScript's native `push` instead of `pushAll` (#236 by @i-am-the-slime)

- Implements `ST.push` via a call to JavaScript's native `push` instead of `pushAll` (#236 by @i-am-the-slime)

## [v7.2.1](https://github.com/purescript/purescript-arrays/releases/tag/v7.2.1) - 2023-06-13

Expand Down
12 changes: 12 additions & 0 deletions bench/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package:
name: arrays-bench
build:
strict: true
pedanticPackages: true
dependencies:
- arrays: "*"
- console: ">=6.0.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
- maybe: ">=6.0.0 <7.0.0"
- minibench: ">=4.0.0 <5.0.0"
- prelude: ">=6.0.0 <7.0.0"
7 changes: 4 additions & 3 deletions bench/Data/Array.purs → bench/src/Bench/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ benchArray = do
where

benchMapMaybe = do
let shortNats = Array.range 0 100
longNats = Array.range 0 10000
onlyEven x = if x `mod` 2 == 0 then Just x else Nothing
let
shortNats = Array.range 0 100
longNats = Array.range 0 10000
onlyEven x = if x `mod` 2 == 0 then Just x else Nothing

log $ "mapMaybe (" <> show (Array.length shortNats) <> ")"
benchWith 1000 \_ -> Array.mapMaybe onlyEven shortNats
Expand Down
File renamed without changes.
39 changes: 0 additions & 39 deletions bower.json

This file was deleted.

23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test",
"bench:build": "pulp build --include bench -- --censor-lib --strict",
"bench:run": "node --expose-gc -e \"require('./output/Bench.Main/index.js').main()\"",
"bench": "npm run bench:build && npm run bench:run"
"build": "spago build -p arrays",
"test": "spago test -p arrays",
"bench:build": "spago build -p arrays-bench",
"bench:run": "node --expose-gc -e \"import('./output/Bench.Main/index.js').then(m => m.main())\"",
"bench": "npm run bench:build && npm run bench:run",
"lint": "oxlint --deny-warnings src test",
"format": "purs-tidy format-in-place src test bench/src && oxfmt --write .",
"format:check": "purs-tidy check src test bench/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"
}
}
38 changes: 38 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package:
name: arrays
description: Utility functions for the Array type - JavaScript's native arrays.
build:
strict: true
pedanticPackages: true
publish:
version: 7.3.1
license: BSD-3-Clause
location:
githubOwner: purescript
githubRepo: purescript-arrays
dependencies:
- bifunctors: ">=6.0.0 <7.0.0"
- control: ">=6.0.0 <7.0.0"
- foldable-traversable: ">=6.0.0 <7.0.0"
- functions: ">=6.0.0 <7.0.0"
- maybe: ">=6.0.0 <7.0.0"
- nonempty: ">=7.0.0 <8.0.0"
- partial: ">=4.0.0 <5.0.0"
- prelude: ">=6.0.0 <7.0.0"
- safe-coerce: ">=2.0.0 <3.0.0"
- st: ">=6.2.0 <7.0.0"
- tailrec: ">=6.0.0 <7.0.0"
- tuples: ">=7.0.0 <8.0.0"
- unfoldable: ">=6.0.0 <7.0.0"
- unsafe-coerce: ">=6.0.0 <7.0.0"
test:
main: Test.Main
strict: true
pedanticPackages: true
dependencies:
- assert: ">=6.0.0 <7.0.0"
- console: ">=6.0.0 <7.0.0"
- const: ">=6.0.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
- orders: ">=6.0.0 <7.0.0"
workspace: {}
27 changes: 17 additions & 10 deletions src/Data/Array.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// Arrays with a known size are allocated upfront and filled below.
// Initializing those slots first would do the work twice.

//------------------------------------------------------------------------------
// Array creation --------------------------------------------------------------
//------------------------------------------------------------------------------

export const rangeImpl = function (start, end) {
var step = start > end ? -1 : 1;
// oxlint-disable-next-line unicorn/no-new-array
var result = new Array(step * (end - start) + 1);
var i = start, n = 0;
var i = start,
n = 0;
while (i !== end) {
result[n++] = i;
i += step;
Expand All @@ -18,6 +23,7 @@ var replicateFill = function (count, value) {
if (count < 1) {
return [];
}
// oxlint-disable-next-line unicorn/no-new-array
var result = new Array(count);
return result.fill(value);
};
Expand All @@ -32,7 +38,8 @@ var replicatePolyfill = function (count, value) {
};

// In browsers that have Array.prototype.fill we use it, as it's faster.
export const replicateImpl = typeof Array.prototype.fill === "function" ? replicateFill : replicatePolyfill;
export const replicateImpl =
typeof Array.prototype.fill === "function" ? replicateFill : replicatePolyfill;

export const fromFoldableImpl = (function () {
function Cons(head, tail) {
Expand Down Expand Up @@ -84,7 +91,7 @@ export const unconsImpl = function (empty, next, xs) {
//------------------------------------------------------------------------------

export const indexImpl = function (just, nothing, xs, i) {
return i < 0 || i >= xs.length ? nothing : just(xs[i]);
return i < 0 || i >= xs.length ? nothing : just(xs[i]);
};

export const findMapImpl = function (nothing, isJust, f, xs) {
Expand Down Expand Up @@ -161,20 +168,19 @@ export const filterImpl = function (f, xs) {

export const partitionImpl = function (f, xs) {
var yes = [];
var no = [];
var no = [];
for (var i = 0; i < xs.length; i++) {
var x = xs[i];
if (f(x))
yes.push(x);
else
no.push(x);
if (f(x)) yes.push(x);
else no.push(x);
}
return { yes: yes, no: no };
};

export const scanlImpl = function (f, b, xs) {
var len = xs.length;
var acc = b;
// oxlint-disable-next-line unicorn/no-new-array
var out = new Array(len);
for (var i = 0; i < len; i++) {
acc = f(acc)(xs[i]);
Expand All @@ -186,6 +192,7 @@ export const scanlImpl = function (f, b, xs) {
export const scanrImpl = function (f, b, xs) {
var len = xs.length;
var acc = b;
// oxlint-disable-next-line unicorn/no-new-array
var out = new Array(len);
for (var i = len - 1; i >= 0; i--) {
acc = f(xs[i])(acc);
Expand Down Expand Up @@ -222,8 +229,7 @@ export const sortByImpl = (function () {
if (c > 0) {
xs1[k++] = y;
++j;
}
else {
} else {
xs1[k++] = x;
++i;
}
Expand Down Expand Up @@ -262,6 +268,7 @@ export const sliceImpl = function (s, e, l) {

export const zipWithImpl = function (f, xs, ys) {
var l = xs.length < ys.length ? xs.length : ys.length;
// oxlint-disable-next-line unicorn/no-new-array
var result = new Array(l);
for (var i = 0; i < l; i++) {
result[i] = f(xs[i])(ys[i]);
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ import Data.Foldable (class Foldable, traverse_)
import Data.Foldable as F
import Data.Function.Uncurried (Fn2, Fn3, Fn4, Fn5, runFn2, runFn3, runFn4, runFn5)
import Data.FunctorWithIndex as FWI
import Data.Maybe (Maybe(..), maybe, isJust, fromJust, isNothing)
import Data.Maybe (Maybe(..), fromJust, isJust, isNothing, maybe)
import Data.Traversable (sequence, traverse)
import Data.Tuple (Tuple(..), fst, snd)
import Data.Unfoldable (class Unfoldable, unfoldr)
Expand Down
Loading
Loading