Skip to content

Commit eb750d4

Browse files
JordanMartinezthomashoneyman
andauthoredJun 13, 2023
Update non-ST FFI to use Fn (#235)
* Update non-ST FFI to use Fn * Add changelog * Add dependency on functions * Update bower.json --------- Co-authored-by: Thomas Honeyman <[email protected]>
1 parent 568f07e commit eb750d4

File tree

6 files changed

+329
-372
lines changed

6 files changed

+329
-372
lines changed
 

‎CHANGELOG.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,27 @@ Other improvements:
1515
## [v7.2.0](https://github.com/purescript/purescript-arrays/releases/tag/v7.2.0) - 2023-01-17
1616

1717
New features:
18+
1819
- Add `prependArray` (#224 by @JordanMartinez)
1920
- Add `Data.Array.ST.length` (#239 by @Blugatroff)
2021

2122
Other improvements:
23+
2224
- Use more efficient implementation for `mapWithIndex` (#233 by @JordanMartinez)
25+
- Updates non-`ST` FFI to use uncurried functions via `Fn` types (#235 by @JordanMartinez)
2326
- Updates `ST` FFI to use uncurried functions via `STFnX` types (#234 by @JordanMartinez)
2427

2528
## [v7.1.0](https://github.com/purescript/purescript-arrays/releases/tag/v7.1.0) - 2022-08-06
2629

2730
New features:
31+
2832
- Added `transpose` to `Array` (#225 by @newlandsvalley and @JordanMartinez)
2933
- Added `transpose` and `transpose' `to `Array.NonEmpty` (#227 by @newlandsvalley and @JordanMartinez)
3034

3135
## [v7.0.0](https://github.com/purescript/purescript-arrays/releases/tag/v7.0.0) - 2022-04-27
3236

3337
Breaking changes:
38+
3439
- Migrate FFI to ES modules (#218 by @kl0tl and @JordanMartinez)
3540
- Drop deprecated `group'` and `empty` (#219 by @JordanMartinez)
3641

@@ -39,21 +44,25 @@ New features:
3944
Bugfixes:
4045

4146
Other improvements:
47+
4248
- Fixed minor documentation issue with `find` (#216 by @JamieBallingall)
4349

4450
## [v6.0.1](https://github.com/purescript/purescript-arrays/releases/tag/v6.0.1) - 2021-04-19
4551

4652
Other improvements:
53+
4754
- Fixed warnings revealed by `v0.14.1` PS release (#213 by @JordanMartinez)
4855

4956
## [v6.0.0](https://github.com/purescript/purescript-arrays/releases/tag/v6.0.0) - 2021-02-26
5057

5158
Breaking changes:
59+
5260
- Added support for PureScript 0.14 and dropped support for all previous versions (#181)
5361
- Renamed `Data.Array.ST.empty` to `Data.Array.ST.new` (#191, #198)
5462
- Renamed `group'` to `groupAll` (#194, #200)
5563

5664
New features:
65+
5766
- Added specialized versions of the functions from `Data.Foldable` (#201):
5867
- Added `foldl`, `foldr`, `foldMap`, `fold`, `intercalate` to `Array`
5968
- Added `foldl1`, `foldr1`, `foldMap1`, `foldl1`, `intercalate` to `Array.NonEmpty`
@@ -62,9 +71,11 @@ New features:
6271
- Added `mapWithIndex`, `groupBy` to `Array.NonEmpty` (#201, #164)
6372

6473
Bugfixes:
74+
6575
- Fixed `sort`, so `undefined` is sorted by comparison function and not simply moved to the end of the array (#195, #197)
6676

6777
Other improvements:
78+
6879
- Generated changelog and added PR template (#208, #209)
6980
- Added benchmarking (#178)
7081
- Migrated to GitHub Actions for CI (#187, #169)
@@ -98,7 +109,7 @@ Fixed issue with `fill` polyfill not being included in the bundle by `purs bundl
98109

99110
## [v5.1.0](https://github.com/purescript/purescript-arrays/releases/tag/v5.1.0) - 2018-09-25
100111

101-
* Make `groupBy` stable https://github.com/purescript/purescript-arrays/pull/148 (@LiamGoodacre)
112+
- Make `groupBy` stable https://github.com/purescript/purescript-arrays/pull/148 (@LiamGoodacre)
102113

103114
## [v5.0.0](https://github.com/purescript/purescript-arrays/releases/tag/v5.0.0) - 2018-05-23
104115

@@ -119,8 +130,8 @@ Fixed issue with `fill` polyfill not being included in the bundle by `purs bundl
119130

120131
## [v4.2.2](https://github.com/purescript/purescript-arrays/releases/tag/v4.2.2) - 2017-12-16
121132

122-
* Add examples to the docs for most functions in `Data.Array` (@csicar)
123-
* Remove some redundant parentheses (@matthewleon)
133+
- Add examples to the docs for most functions in `Data.Array` (@csicar)
134+
- Remove some redundant parentheses (@matthewleon)
124135

125136
## [v4.2.1](https://github.com/purescript/purescript-arrays/releases/tag/v4.2.1) - 2017-10-01
126137

@@ -136,8 +147,8 @@ Fix some bugs in `Data.Array.ST.Partial` (@mhuisi)
136147

137148
## [v4.1.1](https://github.com/purescript/purescript-arrays/releases/tag/v4.1.1) - 2017-06-20
138149

139-
* Improve performance of `unzip`; this function is now O(n) instead of O(n^2)
140-
* Various documentation improvements
150+
- Improve performance of `unzip`; this function is now O(n) instead of O(n^2)
151+
- Various documentation improvements
141152

142153
## [v4.1.0](https://github.com/purescript/purescript-arrays/releases/tag/v4.1.0) - 2017-05-28
143154

@@ -259,6 +270,7 @@ This release works with versions 0.7.\* of the PureScript compiler. It will not
259270
## [v0.4.0-rc.2](https://github.com/purescript/purescript-arrays/releases/tag/v0.4.0-rc.2) - 2015-06-07
260271

261272
Updates for parity with `purescript-lists`:
273+
262274
- Added `insert`, `insertBy`, `alterAt`, `union`, `unionBy`
263275
- The `insertAt`, `modifyAt`, `deleteAt`... functions now return `Nothing` when given an out of range index
264276

@@ -288,8 +300,6 @@ Add `modifyAt`.
288300

289301
## [v0.3.2](https://github.com/purescript/purescript-arrays/releases/tag/v0.3.2) - 2015-02-18
290302

291-
292-
293303
## [v0.3.1](https://github.com/purescript/purescript-arrays/releases/tag/v0.3.1) - 2015-01-24
294304

295305
Add `take` and `drop`.
@@ -308,12 +318,8 @@ Include `(..)` operator.
308318

309319
## [v0.1.8](https://github.com/purescript/purescript-arrays/releases/tag/v0.1.8) - 2014-05-30
310320

311-
312-
313321
## [v0.1.7](https://github.com/purescript/purescript-arrays/releases/tag/v0.1.7) - 2014-05-29
314322

315-
316-
317323
## [v0.1.6](https://github.com/purescript/purescript-arrays/releases/tag/v0.1.6) - 2014-05-22
318324

319325
- Added `delete`, `deleteBy`, `(\\)` (garyb)

‎bower.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"purescript-bifunctors": "^6.0.0",
1919
"purescript-control": "^6.0.0",
2020
"purescript-foldable-traversable": "^6.0.0",
21+
"purescript-functions": "^6.0.0",
2122
"purescript-maybe": "^6.0.0",
2223
"purescript-nonempty": "^7.0.0",
2324
"purescript-partial": "^4.0.0",

‎src/Data/Array.js

+121-209
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,37 @@
22
// Array creation --------------------------------------------------------------
33
//------------------------------------------------------------------------------
44

5-
export const range = function (start) {
6-
return function (end) {
7-
var step = start > end ? -1 : 1;
8-
var result = new Array(step * (end - start) + 1);
9-
var i = start, n = 0;
10-
while (i !== end) {
11-
result[n++] = i;
12-
i += step;
13-
}
14-
result[n] = i;
15-
return result;
16-
};
5+
export const rangeImpl = function (start, end) {
6+
var step = start > end ? -1 : 1;
7+
var result = new Array(step * (end - start) + 1);
8+
var i = start, n = 0;
9+
while (i !== end) {
10+
result[n++] = i;
11+
i += step;
12+
}
13+
result[n] = i;
14+
return result;
1715
};
1816

19-
var replicateFill = function (count) {
20-
return function (value) {
21-
if (count < 1) {
22-
return [];
23-
}
24-
var result = new Array(count);
25-
return result.fill(value);
26-
};
17+
var replicateFill = function (count, value) {
18+
if (count < 1) {
19+
return [];
20+
}
21+
var result = new Array(count);
22+
return result.fill(value);
2723
};
2824

29-
var replicatePolyfill = function (count) {
30-
return function (value) {
31-
var result = [];
32-
var n = 0;
33-
for (var i = 0; i < count; i++) {
34-
result[n++] = value;
35-
}
36-
return result;
37-
};
25+
var replicatePolyfill = function (count, value) {
26+
var result = [];
27+
var n = 0;
28+
for (var i = 0; i < count; i++) {
29+
result[n++] = value;
30+
}
31+
return result;
3832
};
3933

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

4337
export const fromFoldableImpl = (function () {
4438
function Cons(head, tail) {
@@ -64,10 +58,8 @@ export const fromFoldableImpl = (function () {
6458
return result;
6559
}
6660

67-
return function (foldr) {
68-
return function (xs) {
69-
return listToArray(foldr(curryCons)(emptyList)(xs));
70-
};
61+
return function (foldr, xs) {
62+
return listToArray(foldr(curryCons)(emptyList)(xs));
7163
};
7264
})();
7365

@@ -83,109 +75,59 @@ export const length = function (xs) {
8375
// Non-indexed reads -----------------------------------------------------------
8476
//------------------------------------------------------------------------------
8577

86-
export const unconsImpl = function (empty) {
87-
return function (next) {
88-
return function (xs) {
89-
return xs.length === 0 ? empty({}) : next(xs[0])(xs.slice(1));
90-
};
91-
};
78+
export const unconsImpl = function (empty, next, xs) {
79+
return xs.length === 0 ? empty({}) : next(xs[0])(xs.slice(1));
9280
};
9381

9482
//------------------------------------------------------------------------------
9583
// Indexed operations ----------------------------------------------------------
9684
//------------------------------------------------------------------------------
9785

98-
export const indexImpl = function (just) {
99-
return function (nothing) {
100-
return function (xs) {
101-
return function (i) {
102-
return i < 0 || i >= xs.length ? nothing : just(xs[i]);
103-
};
104-
};
105-
};
86+
export const indexImpl = function (just, nothing, xs, i) {
87+
return i < 0 || i >= xs.length ? nothing : just(xs[i]);
10688
};
10789

108-
export const findMapImpl = function (nothing) {
109-
return function (isJust) {
110-
return function (f) {
111-
return function (xs) {
112-
for (var i = 0; i < xs.length; i++) {
113-
var result = f(xs[i]);
114-
if (isJust(result)) return result;
115-
}
116-
return nothing;
117-
};
118-
};
119-
};
90+
export const findMapImpl = function (nothing, isJust, f, xs) {
91+
for (var i = 0; i < xs.length; i++) {
92+
var result = f(xs[i]);
93+
if (isJust(result)) return result;
94+
}
95+
return nothing;
12096
};
12197

122-
export const findIndexImpl = function (just) {
123-
return function (nothing) {
124-
return function (f) {
125-
return function (xs) {
126-
for (var i = 0, l = xs.length; i < l; i++) {
127-
if (f(xs[i])) return just(i);
128-
}
129-
return nothing;
130-
};
131-
};
132-
};
98+
export const findIndexImpl = function (just, nothing, f, xs) {
99+
for (var i = 0, l = xs.length; i < l; i++) {
100+
if (f(xs[i])) return just(i);
101+
}
102+
return nothing;
133103
};
134104

135-
export const findLastIndexImpl = function (just) {
136-
return function (nothing) {
137-
return function (f) {
138-
return function (xs) {
139-
for (var i = xs.length - 1; i >= 0; i--) {
140-
if (f(xs[i])) return just(i);
141-
}
142-
return nothing;
143-
};
144-
};
145-
};
105+
export const findLastIndexImpl = function (just, nothing, f, xs) {
106+
for (var i = xs.length - 1; i >= 0; i--) {
107+
if (f(xs[i])) return just(i);
108+
}
109+
return nothing;
146110
};
147111

148-
export const _insertAt = function (just) {
149-
return function (nothing) {
150-
return function (i) {
151-
return function (a) {
152-
return function (l) {
153-
if (i < 0 || i > l.length) return nothing;
154-
var l1 = l.slice();
155-
l1.splice(i, 0, a);
156-
return just(l1);
157-
};
158-
};
159-
};
160-
};
112+
export const _insertAt = function (just, nothing, i, a, l) {
113+
if (i < 0 || i > l.length) return nothing;
114+
var l1 = l.slice();
115+
l1.splice(i, 0, a);
116+
return just(l1);
161117
};
162118

163-
export const _deleteAt = function (just) {
164-
return function (nothing) {
165-
return function (i) {
166-
return function (l) {
167-
if (i < 0 || i >= l.length) return nothing;
168-
var l1 = l.slice();
169-
l1.splice(i, 1);
170-
return just(l1);
171-
};
172-
};
173-
};
119+
export const _deleteAt = function (just, nothing, i, l) {
120+
if (i < 0 || i >= l.length) return nothing;
121+
var l1 = l.slice();
122+
l1.splice(i, 1);
123+
return just(l1);
174124
};
175125

176-
export const _updateAt = function (just) {
177-
return function (nothing) {
178-
return function (i) {
179-
return function (a) {
180-
return function (l) {
181-
if (i < 0 || i >= l.length) return nothing;
182-
var l1 = l.slice();
183-
l1[i] = a;
184-
return just(l1);
185-
};
186-
};
187-
};
188-
};
126+
export const _updateAt = function (just, nothing, i, a, l) {
127+
if (i < 0 || i >= l.length) return nothing;
128+
var l1 = l.slice();
129+
l1[i] = a;
130+
return just(l1);
189131
};
190132

191133
//------------------------------------------------------------------------------
@@ -213,55 +155,43 @@ export const concat = function (xss) {
213155
return result;
214156
};
215157

216-
export const filter = function (f) {
217-
return function (xs) {
218-
return xs.filter(f);
219-
};
158+
export const filterImpl = function (f, xs) {
159+
return xs.filter(f);
220160
};
221161

222-
export const partition = function (f) {
223-
return function (xs) {
224-
var yes = [];
225-
var no = [];
226-
for (var i = 0; i < xs.length; i++) {
227-
var x = xs[i];
228-
if (f(x))
229-
yes.push(x);
230-
else
231-
no.push(x);
232-
}
233-
return { yes: yes, no: no };
234-
};
162+
export const partitionImpl = function (f, xs) {
163+
var yes = [];
164+
var no = [];
165+
for (var i = 0; i < xs.length; i++) {
166+
var x = xs[i];
167+
if (f(x))
168+
yes.push(x);
169+
else
170+
no.push(x);
171+
}
172+
return { yes: yes, no: no };
235173
};
236174

237-
export const scanl = function (f) {
238-
return function (b) {
239-
return function (xs) {
240-
var len = xs.length;
241-
var acc = b;
242-
var out = new Array(len);
243-
for (var i = 0; i < len; i++) {
244-
acc = f(acc)(xs[i]);
245-
out[i] = acc;
246-
}
247-
return out;
248-
};
249-
};
175+
export const scanlImpl = function (f, b, xs) {
176+
var len = xs.length;
177+
var acc = b;
178+
var out = new Array(len);
179+
for (var i = 0; i < len; i++) {
180+
acc = f(acc)(xs[i]);
181+
out[i] = acc;
182+
}
183+
return out;
250184
};
251185

252-
export const scanr = function (f) {
253-
return function (b) {
254-
return function (xs) {
255-
var len = xs.length;
256-
var acc = b;
257-
var out = new Array(len);
258-
for (var i = len - 1; i >= 0; i--) {
259-
acc = f(xs[i])(acc);
260-
out[i] = acc;
261-
}
262-
return out;
263-
};
264-
};
186+
export const scanrImpl = function (f, b, xs) {
187+
var len = xs.length;
188+
var acc = b;
189+
var out = new Array(len);
190+
for (var i = len - 1; i >= 0; i--) {
191+
acc = f(xs[i])(acc);
192+
out[i] = acc;
193+
}
194+
return out;
265195
};
266196

267197
//------------------------------------------------------------------------------
@@ -306,81 +236,63 @@ export const sortByImpl = (function () {
306236
}
307237
}
308238

309-
return function (compare) {
310-
return function (fromOrdering) {
311-
return function (xs) {
312-
var out;
239+
return function (compare, fromOrdering, xs) {
240+
var out;
313241

314-
if (xs.length < 2) return xs;
242+
if (xs.length < 2) return xs;
315243

316-
out = xs.slice(0);
317-
mergeFromTo(compare, fromOrdering, out, xs.slice(0), 0, xs.length);
244+
out = xs.slice(0);
245+
mergeFromTo(compare, fromOrdering, out, xs.slice(0), 0, xs.length);
318246

319-
return out;
320-
};
321-
};
247+
return out;
322248
};
323249
})();
324250

325251
//------------------------------------------------------------------------------
326252
// Subarrays -------------------------------------------------------------------
327253
//------------------------------------------------------------------------------
328254

329-
export const slice = function (s) {
330-
return function (e) {
331-
return function (l) {
332-
return l.slice(s, e);
333-
};
334-
};
255+
export const sliceImpl = function (s, e, l) {
256+
return l.slice(s, e);
335257
};
336258

337259
//------------------------------------------------------------------------------
338260
// Zipping ---------------------------------------------------------------------
339261
//------------------------------------------------------------------------------
340262

341-
export const zipWith = function (f) {
342-
return function (xs) {
343-
return function (ys) {
344-
var l = xs.length < ys.length ? xs.length : ys.length;
345-
var result = new Array(l);
346-
for (var i = 0; i < l; i++) {
347-
result[i] = f(xs[i])(ys[i]);
348-
}
349-
return result;
350-
};
351-
};
263+
export const zipWithImpl = function (f, xs, ys) {
264+
var l = xs.length < ys.length ? xs.length : ys.length;
265+
var result = new Array(l);
266+
for (var i = 0; i < l; i++) {
267+
result[i] = f(xs[i])(ys[i]);
268+
}
269+
return result;
352270
};
353271

354272
//------------------------------------------------------------------------------
355273
// Folding ---------------------------------------------------------------------
356274
//------------------------------------------------------------------------------
357275

358-
export const any = function (p) {
359-
return function (xs) {
360-
var len = xs.length;
361-
for (var i = 0; i < len; i++) {
362-
if (p(xs[i])) return true;
363-
}
364-
return false;
365-
};
276+
export const anyImpl = function (p, xs) {
277+
var len = xs.length;
278+
for (var i = 0; i < len; i++) {
279+
if (p(xs[i])) return true;
280+
}
281+
return false;
366282
};
367283

368-
export const all = function (p) {
369-
return function (xs) {
370-
var len = xs.length;
371-
for (var i = 0; i < len; i++) {
372-
if (!p(xs[i])) return false;
373-
}
374-
return true;
375-
};
284+
export const allImpl = function (p, xs) {
285+
var len = xs.length;
286+
for (var i = 0; i < len; i++) {
287+
if (!p(xs[i])) return false;
288+
}
289+
return true;
376290
};
377291

378292
//------------------------------------------------------------------------------
379293
// Partial ---------------------------------------------------------------------
380294
//------------------------------------------------------------------------------
381295

382-
export const unsafeIndexImpl = function (xs) {
383-
return function (n) {
384-
return xs[n];
385-
};
296+
export const unsafeIndexImpl = function (xs, n) {
297+
return xs[n];
386298
};

‎src/Data/Array.purs

+144-99
Large diffs are not rendered by default.

‎src/Data/Array/NonEmpty/Internal.js

+35-43
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
export const foldr1Impl = function (f) {
2-
return function (xs) {
3-
var acc = xs[xs.length - 1];
4-
for (var i = xs.length - 2; i >= 0; i--) {
5-
acc = f(xs[i])(acc);
6-
}
7-
return acc;
8-
};
1+
export const foldr1Impl = function (f, xs) {
2+
var acc = xs[xs.length - 1];
3+
for (var i = xs.length - 2; i >= 0; i--) {
4+
acc = f(xs[i])(acc);
5+
}
6+
return acc;
97
};
108

11-
export const foldl1Impl = function (f) {
12-
return function (xs) {
13-
var acc = xs[0];
14-
var len = xs.length;
15-
for (var i = 1; i < len; i++) {
16-
acc = f(acc)(xs[i]);
17-
}
18-
return acc;
19-
};
9+
export const foldl1Impl = function (f, xs) {
10+
var acc = xs[0];
11+
var len = xs.length;
12+
for (var i = 1; i < len; i++) {
13+
acc = f(acc)(xs[i]);
14+
}
15+
return acc;
2016
};
2117

2218
export const traverse1Impl = function () {
@@ -51,35 +47,31 @@ export const traverse1Impl = function () {
5147
return arr;
5248
}
5349

54-
return function (apply) {
55-
return function (map) {
56-
return function (f) {
57-
var buildFrom = function (x, ys) {
58-
return apply(map(consList)(f(x)))(ys);
59-
};
50+
return function (apply, map, f) {
51+
var buildFrom = function (x, ys) {
52+
return apply(map(consList)(f(x)))(ys);
53+
};
6054

61-
var go = function (acc, currentLen, xs) {
62-
if (currentLen === 0) {
63-
return acc;
64-
} else {
65-
var last = xs[currentLen - 1];
66-
return new Cont(function () {
67-
var built = go(buildFrom(last, acc), currentLen - 1, xs);
68-
return built;
69-
});
70-
}
71-
};
55+
var go = function (acc, currentLen, xs) {
56+
if (currentLen === 0) {
57+
return acc;
58+
} else {
59+
var last = xs[currentLen - 1];
60+
return new Cont(function () {
61+
var built = go(buildFrom(last, acc), currentLen - 1, xs);
62+
return built;
63+
});
64+
}
65+
};
7266

73-
return function (array) {
74-
var acc = map(finalCell)(f(array[array.length - 1]));
75-
var result = go(acc, array.length - 1, array);
76-
while (result instanceof Cont) {
77-
result = result.fn();
78-
}
67+
return function (array) {
68+
var acc = map(finalCell)(f(array[array.length - 1]));
69+
var result = go(acc, array.length - 1, array);
70+
while (result instanceof Cont) {
71+
result = result.fn();
72+
}
7973

80-
return map(listToArray)(result);
81-
};
82-
};
74+
return map(listToArray)(result);
8375
};
8476
};
8577
}();

‎src/Data/Array/NonEmpty/Internal.purs

+11-10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Control.Alt (class Alt)
1313
import Data.Eq (class Eq1)
1414
import Data.Foldable (class Foldable)
1515
import Data.FoldableWithIndex (class FoldableWithIndex)
16+
import Data.Function.Uncurried (Fn2, Fn3, runFn2, runFn3)
1617
import Data.FunctorWithIndex (class FunctorWithIndex)
1718
import Data.Ord (class Ord1)
1819
import Data.Semigroup.Foldable (class Foldable1, foldMap1DefaultL)
@@ -49,15 +50,15 @@ derive newtype instance foldableWithIndexNonEmptyArray :: FoldableWithIndex Int
4950

5051
instance foldable1NonEmptyArray :: Foldable1 NonEmptyArray where
5152
foldMap1 = foldMap1DefaultL
52-
foldr1 = foldr1Impl
53-
foldl1 = foldl1Impl
53+
foldr1 = runFn2 foldr1Impl
54+
foldl1 = runFn2 foldl1Impl
5455

5556
derive newtype instance unfoldable1NonEmptyArray :: Unfoldable1 NonEmptyArray
5657
derive newtype instance traversableNonEmptyArray :: Traversable NonEmptyArray
5758
derive newtype instance traversableWithIndexNonEmptyArray :: TraversableWithIndex Int NonEmptyArray
5859

5960
instance traversable1NonEmptyArray :: Traversable1 NonEmptyArray where
60-
traverse1 = traverse1Impl apply map
61+
traverse1 f = runFn3 traverse1Impl apply map f
6162
sequence1 = sequence1Default
6263

6364
derive newtype instance applyNonEmptyArray :: Apply NonEmptyArray
@@ -71,13 +72,13 @@ derive newtype instance monadNonEmptyArray :: Monad NonEmptyArray
7172
derive newtype instance altNonEmptyArray :: Alt NonEmptyArray
7273

7374
-- we use FFI here to avoid the unncessary copy created by `tail`
74-
foreign import foldr1Impl :: forall a. (a -> a -> a) -> NonEmptyArray a -> a
75-
foreign import foldl1Impl :: forall a. (a -> a -> a) -> NonEmptyArray a -> a
75+
foreign import foldr1Impl :: forall a. Fn2 (a -> a -> a) (NonEmptyArray a) a
76+
foreign import foldl1Impl :: forall a. Fn2 (a -> a -> a) (NonEmptyArray a) a
7677

7778
foreign import traverse1Impl
7879
:: forall m a b
79-
. (forall a' b'. (m (a' -> b') -> m a' -> m b'))
80-
-> (forall a' b'. (a' -> b') -> m a' -> m b')
81-
-> (a -> m b)
82-
-> NonEmptyArray a
83-
-> m (NonEmptyArray b)
80+
. Fn3
81+
(forall a' b'. (m (a' -> b') -> m a' -> m b'))
82+
(forall a' b'. (a' -> b') -> m a' -> m b')
83+
(a -> m b)
84+
(NonEmptyArray a -> m (NonEmptyArray b))

0 commit comments

Comments
 (0)
Please sign in to comment.