@fncts/base 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_cjs/collection/Iterable/api.cjs +3 -2
- package/_cjs/collection/Iterable/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/api.cjs +25 -12
- package/_cjs/collection/immutable/Conc/api.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/api.cjs +20 -8
- package/_cjs/collection/immutable/HashMap/api.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/definition.cjs +3 -2
- package/_cjs/collection/immutable/HashMap/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/internal.cjs +9 -7
- package/_cjs/collection/immutable/HashMap/internal.cjs.map +1 -1
- package/_cjs/collection/immutable/HashSet/api.cjs +7 -6
- package/_cjs/collection/immutable/HashSet/api.cjs.map +1 -1
- package/_cjs/collection/immutable/ImmutableArray/api.cjs +18 -17
- package/_cjs/collection/immutable/ImmutableArray/api.cjs.map +1 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/constructors.cjs +2 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/constructors.cjs.map +1 -1
- package/_cjs/collection/immutable/List/api.cjs +3 -2
- package/_cjs/collection/immutable/List/api.cjs.map +1 -1
- package/_cjs/collection/immutable/List/definition.cjs +19 -4
- package/_cjs/collection/immutable/List/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/Queue/api.cjs +7 -6
- package/_cjs/collection/immutable/Queue/api.cjs.map +1 -1
- package/_cjs/collection/immutable/RoseTree/api.cjs +1 -1
- package/_cjs/collection/immutable/RoseTree/api.cjs.map +1 -1
- package/_cjs/collection/immutable/SortedMap/api.cjs +23 -22
- package/_cjs/collection/immutable/SortedMap/api.cjs.map +1 -1
- package/_cjs/collection/immutable/SortedMap/iterator.cjs +7 -6
- package/_cjs/collection/immutable/SortedMap/iterator.cjs.map +1 -1
- package/_cjs/collection/immutable/Vector/api.cjs +62 -19
- package/_cjs/collection/immutable/Vector/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Vector/definition.cjs.map +1 -1
- package/_cjs/collection/mutable/HashMap.cjs +6 -19
- package/_cjs/collection/mutable/HashMap.cjs.map +1 -1
- package/_cjs/control/CompletablePromise.cjs +21 -0
- package/_cjs/control/CompletablePromise.cjs.map +1 -0
- package/_cjs/control/Z/api.cjs +1 -1
- package/_cjs/control/Z/api.cjs.map +1 -1
- package/_cjs/control/Z/runtime.cjs +2 -2
- package/_cjs/control/Z/runtime.cjs.map +1 -1
- package/_cjs/data/Branded/definition.cjs +4 -3
- package/_cjs/data/Branded/definition.cjs.map +1 -1
- package/_cjs/data/Cause/api/fold.cjs +8 -7
- package/_cjs/data/Cause/api/fold.cjs.map +1 -1
- package/_cjs/data/Cause/api.cjs +124 -128
- package/_cjs/data/Cause/api.cjs.map +1 -1
- package/_cjs/data/DatumEither/api.cjs +5 -4
- package/_cjs/data/DatumEither/api.cjs.map +1 -1
- package/_cjs/data/Decoder/api.cjs +2 -1
- package/_cjs/data/Decoder/api.cjs.map +1 -1
- package/_cjs/data/Either/api/alignWith.cjs +2 -1
- package/_cjs/data/Either/api/alignWith.cjs.map +1 -1
- package/_cjs/data/Either/api.cjs +25 -16
- package/_cjs/data/Either/api.cjs.map +1 -1
- package/_cjs/data/Either/constructors.cjs +10 -9
- package/_cjs/data/Either/constructors.cjs.map +1 -1
- package/_cjs/data/Either/definition.cjs +34 -6
- package/_cjs/data/Either/definition.cjs.map +1 -1
- package/_cjs/data/Either/instances.cjs +7 -6
- package/_cjs/data/Either/instances.cjs.map +1 -1
- package/_cjs/data/EitherT/api.cjs +4 -3
- package/_cjs/data/EitherT/api.cjs.map +1 -1
- package/_cjs/data/Eq/api.cjs +20 -0
- package/_cjs/data/Eq/api.cjs.map +1 -0
- package/_cjs/data/Eq.cjs +11 -0
- package/_cjs/data/Eq.cjs.map +1 -1
- package/_cjs/data/Equatable/api.cjs +39 -11
- package/_cjs/data/Equatable/api.cjs.map +1 -1
- package/_cjs/data/Equatable/definition.cjs +1 -1
- package/_cjs/data/Equatable/definition.cjs.map +1 -1
- package/_cjs/data/Exit/api.cjs +32 -6
- package/_cjs/data/Exit/api.cjs.map +1 -1
- package/_cjs/data/Exit/constructors.cjs +13 -12
- package/_cjs/data/Exit/constructors.cjs.map +1 -1
- package/_cjs/data/Exit/definition.cjs +11 -6
- package/_cjs/data/Exit/definition.cjs.map +1 -1
- package/_cjs/data/FiberId/api.cjs +16 -15
- package/_cjs/data/FiberId/api.cjs.map +1 -1
- package/_cjs/data/Interval.cjs +2 -1
- package/_cjs/data/Interval.cjs.map +1 -1
- package/_cjs/data/Maybe/api.cjs +8 -7
- package/_cjs/data/Maybe/api.cjs.map +1 -1
- package/_cjs/data/Maybe/constructors.cjs +11 -11
- package/_cjs/data/Maybe/constructors.cjs.map +1 -1
- package/_cjs/data/Maybe/definition.cjs +10 -5
- package/_cjs/data/Maybe/definition.cjs.map +1 -1
- package/_cjs/data/Maybe/instances.cjs +30 -8
- package/_cjs/data/Maybe/instances.cjs.map +1 -1
- package/_cjs/data/Showable/show.cjs +2 -2
- package/_cjs/data/Showable/show.cjs.map +1 -1
- package/_cjs/data/These/destructors.cjs +3 -2
- package/_cjs/data/These/destructors.cjs.map +1 -1
- package/_cjs/data/exceptions/IOError.cjs +25 -0
- package/_cjs/data/exceptions/IOError.cjs.map +1 -0
- package/_cjs/data/exceptions/NoSuchElementError.cjs.map +1 -1
- package/_cjs/data/exceptions.cjs +11 -0
- package/_cjs/data/exceptions.cjs.map +1 -1
- package/_cjs/optics/Lens/definition.cjs +2 -1
- package/_cjs/optics/Lens/definition.cjs.map +1 -1
- package/_cjs/optics/Prism/api/just.cjs +2 -1
- package/_cjs/optics/Prism/api/just.cjs.map +1 -1
- package/_cjs/typeclass/ApplicativeExcept.cjs +2 -1
- package/_cjs/typeclass/ApplicativeExcept.cjs.map +1 -1
- package/_cjs/typeclass/Semialign.cjs +2 -1
- package/_cjs/typeclass/Semialign.cjs.map +1 -1
- package/_cjs/typeclass/Witherable.cjs +2 -1
- package/_cjs/typeclass/Witherable.cjs.map +1 -1
- package/_cjs/typeclass/WitherableWithIndex.cjs +2 -1
- package/_cjs/typeclass/WitherableWithIndex.cjs.map +1 -1
- package/_cjs/typeclass.cjs +2 -2
- package/_cjs/types.cjs +0 -11
- package/_cjs/types.cjs.map +1 -1
- package/_cjs/util/predicates.cjs +4 -0
- package/_cjs/util/predicates.cjs.map +1 -1
- package/_cjs/util/rand/Random.cjs.map +1 -1
- package/_mjs/collection/Iterable/api.mjs +3 -2
- package/_mjs/collection/Iterable/api.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/api.mjs +24 -12
- package/_mjs/collection/immutable/Conc/api.mjs.map +1 -1
- package/_mjs/collection/immutable/HashMap/api.mjs +19 -8
- package/_mjs/collection/immutable/HashMap/api.mjs.map +1 -1
- package/_mjs/collection/immutable/HashMap/definition.mjs +3 -2
- package/_mjs/collection/immutable/HashMap/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/HashMap/internal.mjs +8 -7
- package/_mjs/collection/immutable/HashMap/internal.mjs.map +1 -1
- package/_mjs/collection/immutable/HashSet/api.mjs +7 -6
- package/_mjs/collection/immutable/HashSet/api.mjs.map +1 -1
- package/_mjs/collection/immutable/ImmutableArray/api.mjs +18 -17
- package/_mjs/collection/immutable/ImmutableArray/api.mjs.map +1 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/constructors.mjs +2 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/constructors.mjs.map +1 -1
- package/_mjs/collection/immutable/List/api.mjs +3 -2
- package/_mjs/collection/immutable/List/api.mjs.map +1 -1
- package/_mjs/collection/immutable/List/definition.mjs +13 -2
- package/_mjs/collection/immutable/List/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/Queue/api.mjs +7 -6
- package/_mjs/collection/immutable/Queue/api.mjs.map +1 -1
- package/_mjs/collection/immutable/RoseTree/api.mjs +1 -1
- package/_mjs/collection/immutable/RoseTree/api.mjs.map +1 -1
- package/_mjs/collection/immutable/SortedMap/api.mjs +23 -22
- package/_mjs/collection/immutable/SortedMap/api.mjs.map +1 -1
- package/_mjs/collection/immutable/SortedMap/iterator.mjs +7 -6
- package/_mjs/collection/immutable/SortedMap/iterator.mjs.map +1 -1
- package/_mjs/collection/immutable/Vector/api.mjs +54 -16
- package/_mjs/collection/immutable/Vector/api.mjs.map +1 -1
- package/_mjs/collection/immutable/Vector/definition.mjs.map +1 -1
- package/_mjs/collection/mutable/HashMap.mjs +6 -5
- package/_mjs/collection/mutable/HashMap.mjs.map +1 -1
- package/_mjs/control/CompletablePromise.mjs +15 -0
- package/_mjs/control/CompletablePromise.mjs.map +1 -0
- package/_mjs/control/Z/api.mjs +1 -1
- package/_mjs/control/Z/api.mjs.map +1 -1
- package/_mjs/control/Z/runtime.mjs +2 -2
- package/_mjs/control/Z/runtime.mjs.map +1 -1
- package/_mjs/data/Branded/definition.mjs +4 -3
- package/_mjs/data/Branded/definition.mjs.map +1 -1
- package/_mjs/data/Cause/api/fold.mjs +8 -7
- package/_mjs/data/Cause/api/fold.mjs.map +1 -1
- package/_mjs/data/Cause/api.mjs +123 -127
- package/_mjs/data/Cause/api.mjs.map +1 -1
- package/_mjs/data/DatumEither/api.mjs +5 -4
- package/_mjs/data/DatumEither/api.mjs.map +1 -1
- package/_mjs/data/Decoder/api.mjs +2 -1
- package/_mjs/data/Decoder/api.mjs.map +1 -1
- package/_mjs/data/Either/api/alignWith.mjs +2 -1
- package/_mjs/data/Either/api/alignWith.mjs.map +1 -1
- package/_mjs/data/Either/api.mjs +22 -15
- package/_mjs/data/Either/api.mjs.map +1 -1
- package/_mjs/data/Either/constructors.mjs +10 -9
- package/_mjs/data/Either/constructors.mjs.map +1 -1
- package/_mjs/data/Either/definition.mjs +30 -4
- package/_mjs/data/Either/definition.mjs.map +1 -1
- package/_mjs/data/Either/instances.mjs +7 -6
- package/_mjs/data/Either/instances.mjs.map +1 -1
- package/_mjs/data/EitherT/api.mjs +4 -3
- package/_mjs/data/EitherT/api.mjs.map +1 -1
- package/_mjs/data/Eq/api.mjs +12 -0
- package/_mjs/data/Eq/api.mjs.map +1 -0
- package/_mjs/data/Eq.mjs +1 -0
- package/_mjs/data/Eq.mjs.map +1 -1
- package/_mjs/data/Equatable/api.mjs +35 -8
- package/_mjs/data/Equatable/api.mjs.map +1 -1
- package/_mjs/data/Equatable/definition.mjs +1 -1
- package/_mjs/data/Equatable/definition.mjs.map +1 -1
- package/_mjs/data/Exit/api.mjs +30 -6
- package/_mjs/data/Exit/api.mjs.map +1 -1
- package/_mjs/data/Exit/constructors.mjs +13 -12
- package/_mjs/data/Exit/constructors.mjs.map +1 -1
- package/_mjs/data/Exit/definition.mjs +11 -6
- package/_mjs/data/Exit/definition.mjs.map +1 -1
- package/_mjs/data/FiberId/api.mjs +16 -15
- package/_mjs/data/FiberId/api.mjs.map +1 -1
- package/_mjs/data/Interval.mjs +2 -1
- package/_mjs/data/Interval.mjs.map +1 -1
- package/_mjs/data/Maybe/api.mjs +8 -7
- package/_mjs/data/Maybe/api.mjs.map +1 -1
- package/_mjs/data/Maybe/constructors.mjs +11 -11
- package/_mjs/data/Maybe/constructors.mjs.map +1 -1
- package/_mjs/data/Maybe/definition.mjs +10 -5
- package/_mjs/data/Maybe/definition.mjs.map +1 -1
- package/_mjs/data/Maybe/instances.mjs +30 -8
- package/_mjs/data/Maybe/instances.mjs.map +1 -1
- package/_mjs/data/Showable/show.mjs +2 -2
- package/_mjs/data/Showable/show.mjs.map +1 -1
- package/_mjs/data/These/destructors.mjs +3 -2
- package/_mjs/data/These/destructors.mjs.map +1 -1
- package/_mjs/data/exceptions/IOError.mjs +14 -0
- package/_mjs/data/exceptions/IOError.mjs.map +1 -0
- package/_mjs/data/exceptions/NoSuchElementError.mjs.map +1 -1
- package/_mjs/data/exceptions.mjs +1 -0
- package/_mjs/data/exceptions.mjs.map +1 -1
- package/_mjs/optics/Lens/definition.mjs +2 -1
- package/_mjs/optics/Lens/definition.mjs.map +1 -1
- package/_mjs/optics/Prism/api/just.mjs +2 -1
- package/_mjs/optics/Prism/api/just.mjs.map +1 -1
- package/_mjs/typeclass/ApplicativeExcept.mjs +2 -1
- package/_mjs/typeclass/ApplicativeExcept.mjs.map +1 -1
- package/_mjs/typeclass/Semialign.mjs +2 -1
- package/_mjs/typeclass/Semialign.mjs.map +1 -1
- package/_mjs/typeclass/Witherable.mjs +2 -1
- package/_mjs/typeclass/Witherable.mjs.map +1 -1
- package/_mjs/typeclass/WitherableWithIndex.mjs +2 -1
- package/_mjs/typeclass/WitherableWithIndex.mjs.map +1 -1
- package/_mjs/typeclass.mjs +1 -1
- package/_mjs/typeclass.mjs.map +1 -1
- package/_mjs/types.mjs +0 -1
- package/_mjs/types.mjs.map +1 -1
- package/_mjs/util/predicates.mjs +3 -0
- package/_mjs/util/predicates.mjs.map +1 -1
- package/_mjs/util/rand/Random.mjs +2 -1
- package/_mjs/util/rand/Random.mjs.map +1 -1
- package/_src/collection/immutable/Conc/api.ts +12 -0
- package/_src/collection/immutable/HashMap/api.ts +11 -0
- package/_src/collection/immutable/HashMap/internal.ts +1 -1
- package/_src/collection/immutable/HashSet/api.ts +4 -4
- package/_src/collection/immutable/List/definition.ts +14 -2
- package/_src/collection/immutable/RoseTree/api.ts +1 -1
- package/_src/collection/immutable/Vector/api.ts +64 -2
- package/_src/collection/immutable/Vector/definition.ts +1 -0
- package/_src/control/CompletablePromise.ts +23 -0
- package/_src/control.ts +1 -0
- package/_src/data/Branded/definition.ts +3 -3
- package/_src/data/Cause/api.ts +33 -40
- package/_src/data/Either/api.ts +10 -0
- package/_src/data/Either/constructors.ts +4 -4
- package/_src/data/Either/definition.ts +29 -2
- package/_src/data/Eq/api.ts +8 -0
- package/_src/data/Eq.ts +1 -0
- package/_src/data/Equatable/api.ts +33 -8
- package/_src/data/Equatable/definition.ts +6 -2
- package/_src/data/Exit/api.ts +26 -0
- package/_src/data/Exit/constructors.ts +7 -7
- package/_src/data/Exit/definition.ts +9 -4
- package/_src/data/FiberId/api.ts +5 -5
- package/_src/data/Maybe/constructors.ts +4 -6
- package/_src/data/Maybe/definition.ts +9 -1
- package/_src/data/Maybe/instances.ts +18 -0
- package/_src/data/Showable/show.ts +2 -2
- package/_src/data/exceptions/IOError.ts +11 -0
- package/_src/data/exceptions/NoSuchElementError.ts +1 -1
- package/_src/data/exceptions.ts +1 -0
- package/_src/data.ts +1 -0
- package/_src/typeclass.ts +1 -1
- package/_src/types.ts +0 -1
- package/_src/util/predicates.ts +4 -0
- package/collection/immutable/Conc/api.d.ts +5 -0
- package/collection/immutable/HashMap/api.d.ts +5 -0
- package/collection/immutable/HashMap/internal.d.ts +1 -2
- package/collection/immutable/List/definition.d.ts +9 -0
- package/collection/immutable/Vector/api.d.ts +30 -3
- package/collection/immutable/Vector/definition.d.ts +1 -0
- package/control/CompletablePromise.d.ts +13 -0
- package/control.d.ts +1 -0
- package/data/Branded/definition.d.ts +3 -2
- package/data/Cause/api.d.ts +1 -1
- package/data/Either/api.d.ts +5 -0
- package/data/Either/constructors.d.ts +2 -2
- package/data/Either/definition.d.ts +15 -2
- package/data/Eq/api.d.ts +6 -0
- package/data/Eq.d.ts +1 -0
- package/data/Equatable/api.d.ts +7 -1
- package/data/Equatable/definition.d.ts +4 -1
- package/data/Exit/api.d.ts +12 -0
- package/data/Exit/constructors.d.ts +5 -5
- package/data/Exit/definition.d.ts +9 -2
- package/data/Maybe/constructors.d.ts +2 -2
- package/data/Maybe/definition.d.ts +9 -1
- package/data/Maybe/instances.d.ts +24 -0
- package/data/exceptions/IOError.d.ts +9 -0
- package/data/exceptions/NoSuchElementError.d.ts +1 -1
- package/data/exceptions.d.ts +1 -0
- package/data.d.ts +1 -0
- package/package.json +1 -1
- package/typeclass.d.ts +1 -1
- package/types.d.ts +0 -1
- package/util/predicates.d.ts +1 -0
- package/_cjs/types/test.cjs +0 -6
- package/_cjs/types/test.cjs.map +0 -1
- package/_mjs/types/test.mjs +0 -2
- package/_mjs/types/test.mjs.map +0 -1
- package/_src/types/test.ts +0 -0
- package/types/test.d.ts +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EqualsContext } from "@fncts/base/data/Equatable";
|
|
2
|
+
|
|
1
3
|
export const enum EitherTag {
|
|
2
4
|
Left = "Left",
|
|
3
5
|
Right = "Right",
|
|
@@ -17,38 +19,63 @@ export interface EitherF extends HKT {
|
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
const IOTypeId = Symbol.for("fncts.io.IO");
|
|
23
|
+
type IOTypeId = typeof IOTypeId;
|
|
24
|
+
|
|
20
25
|
/**
|
|
21
26
|
* @tsplus type fncts.Either
|
|
22
27
|
* @tsplus companion fncts.EitherOps
|
|
23
28
|
*/
|
|
24
29
|
export class Either<E, A> {
|
|
25
30
|
readonly [EitherTypeId]: EitherTypeId = EitherTypeId;
|
|
31
|
+
readonly [IOTypeId]: IOTypeId = IOTypeId;
|
|
32
|
+
readonly trace?: string | undefined = undefined;
|
|
26
33
|
declare [EitherVariance]: {
|
|
27
34
|
readonly _E: (_: never) => E;
|
|
28
35
|
readonly _A: (_: never) => A;
|
|
29
36
|
};
|
|
30
37
|
}
|
|
31
38
|
|
|
39
|
+
const leftHash = Hashable.string(EitherTag.Left);
|
|
40
|
+
|
|
32
41
|
/**
|
|
33
42
|
* @tsplus type fncts.Either.Left
|
|
34
43
|
* @tsplus companion fncts.Either.LeftOps
|
|
35
44
|
*/
|
|
36
45
|
export class Left<E> extends Either<E, never> {
|
|
37
46
|
readonly _tag = EitherTag.Left;
|
|
38
|
-
constructor(readonly left: E) {
|
|
47
|
+
constructor(readonly left: E, readonly trace?: string) {
|
|
39
48
|
super();
|
|
40
49
|
}
|
|
50
|
+
|
|
51
|
+
get [Symbol.hash](): number {
|
|
52
|
+
return Hashable.combine(leftHash, Hashable.unknown(this.left));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[Symbol.equals](that: unknown, context: EqualsContext): boolean {
|
|
56
|
+
return Either.isEither(that) && that.isLeft() && context.comparator(this.left, that.left);
|
|
57
|
+
}
|
|
41
58
|
}
|
|
42
59
|
|
|
60
|
+
const rightHash = Hashable.string(EitherTag.Right);
|
|
61
|
+
|
|
43
62
|
/**
|
|
44
63
|
* @tsplus type fncts.Either.Right
|
|
45
64
|
* @tsplus companion fncts.Either.RightOps
|
|
46
65
|
*/
|
|
47
66
|
export class Right<A> extends Either<never, A> {
|
|
48
67
|
readonly _tag = EitherTag.Right;
|
|
49
|
-
constructor(readonly right: A) {
|
|
68
|
+
constructor(readonly right: A, readonly trace?: string) {
|
|
50
69
|
super();
|
|
51
70
|
}
|
|
71
|
+
|
|
72
|
+
get [Symbol.hash](): number {
|
|
73
|
+
return Hashable.combine(rightHash, Hashable.unknown(this.left));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[Symbol.equals](that: unknown, context: EqualsContext): boolean {
|
|
77
|
+
return Either.isEither(that) && that.isRight() && context.comparator(this.right, that.right);
|
|
78
|
+
}
|
|
52
79
|
}
|
|
53
80
|
|
|
54
81
|
/**
|
package/_src/data/Eq.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EqualsContext } from "@fncts/base/data/Equatable/definition";
|
|
2
|
+
|
|
1
3
|
import { isEquatable } from "@fncts/base/data/Equatable/definition";
|
|
2
4
|
import {
|
|
3
5
|
createCircularEqualCreator,
|
|
@@ -5,30 +7,53 @@ import {
|
|
|
5
7
|
sameValueZeroEqual,
|
|
6
8
|
} from "@fncts/base/data/Equatable/fast-equals";
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
* @tsplus static fncts.EquatableOps deepEquals
|
|
10
|
-
*/
|
|
11
|
-
export const deepEquals = createComparator(
|
|
10
|
+
const deepEqualsComparator = createComparator(
|
|
12
11
|
createCircularEqualCreator((eq) => (a, b, meta) => {
|
|
12
|
+
const equalsContext: EqualsContext = { comparator: deepEquals };
|
|
13
13
|
if (isEquatable(a)) {
|
|
14
|
-
return a[Symbol.equals](b);
|
|
14
|
+
return a[Symbol.equals](b, equalsContext);
|
|
15
15
|
} else if (isEquatable(b)) {
|
|
16
|
-
return b[Symbol.equals](a);
|
|
16
|
+
return b[Symbol.equals](a, equalsContext);
|
|
17
17
|
} else {
|
|
18
18
|
return eq(a, b, meta);
|
|
19
19
|
}
|
|
20
20
|
}),
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @tsplus static fncts.EquatableOps deepEquals
|
|
25
|
+
*/
|
|
26
|
+
export function deepEquals<A>(a: A, b: unknown): boolean {
|
|
27
|
+
const context: EqualsContext = { comparator: deepEquals };
|
|
28
|
+
if (isEquatable(a)) {
|
|
29
|
+
return a[Symbol.equals](b, context);
|
|
30
|
+
} else if (isEquatable(b)) {
|
|
31
|
+
return b[Symbol.equals](a, context);
|
|
32
|
+
} else {
|
|
33
|
+
return deepEqualsComparator(a, b);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
/**
|
|
24
38
|
* @tsplus static fncts.EquatableOps strictEquals
|
|
25
39
|
* @tsplus operator fncts.Equatable ==
|
|
26
40
|
*/
|
|
27
41
|
export function strictEquals<A>(a: A, b: unknown): boolean {
|
|
42
|
+
const context: EqualsContext = {
|
|
43
|
+
comparator: strictEquals,
|
|
44
|
+
};
|
|
28
45
|
if (isEquatable(a)) {
|
|
29
|
-
return a[Symbol.equals](b);
|
|
46
|
+
return a[Symbol.equals](b, context);
|
|
30
47
|
} else if (isEquatable(b)) {
|
|
31
|
-
return b[Symbol.equals](a);
|
|
48
|
+
return b[Symbol.equals](a, context);
|
|
32
49
|
}
|
|
33
50
|
return sameValueZeroEqual(a, b);
|
|
34
51
|
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @tsplus static fncts.EquatableOps strictNotEquals
|
|
55
|
+
* @tsplus operator fncts.Equatable !=
|
|
56
|
+
*/
|
|
57
|
+
export function strictNotEquals<A>(a: A, b: unknown): boolean {
|
|
58
|
+
return !strictEquals(a, b);
|
|
59
|
+
}
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const equalsSymbol: unique symbol = Symbol.for("fncts.Equatable");
|
|
5
5
|
|
|
6
|
+
export interface EqualsContext {
|
|
7
|
+
comparator: (a: unknown, b: unknown) => boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
/**
|
|
7
11
|
* @tsplus type fncts.Equatable
|
|
8
12
|
*/
|
|
9
13
|
export interface Equatable {
|
|
10
|
-
[equalsSymbol](that: unknown): boolean;
|
|
14
|
+
[equalsSymbol](that: unknown, context: EqualsContext): boolean;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
export function isEquatable(u: unknown): u is Equatable {
|
|
14
|
-
return isObject(u) && Symbol.equals
|
|
18
|
+
return isObject(u) && typeof u[Symbol.equals] === "function";
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
/**
|
package/_src/data/Exit/api.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IOError } from "@fncts/base/data/exceptions";
|
|
2
|
+
|
|
1
3
|
import { identity, tuple } from "../function.js";
|
|
2
4
|
import { ExitTag } from "./definition.js";
|
|
3
5
|
|
|
@@ -201,3 +203,27 @@ export function zipWithCause<E, A, G, B, C>(
|
|
|
201
203
|
}
|
|
202
204
|
};
|
|
203
205
|
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Returns the Exit's Success value if it exists
|
|
209
|
+
*
|
|
210
|
+
* @tsplus getter fncts.Exit value
|
|
211
|
+
*/
|
|
212
|
+
export function value<E, A>(self: Exit<E, A>): A | undefined {
|
|
213
|
+
if (self.isFailure()) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
return self.value;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Returns the Exit's Success value if it exists, or throws the pretty-printed Cause if it doesn't
|
|
221
|
+
*
|
|
222
|
+
* @tsplus getter fncts.Exit valueOrThrow
|
|
223
|
+
*/
|
|
224
|
+
export function valueOrThrow<E, A>(self: Exit<E, A>): A {
|
|
225
|
+
if (self.isFailure()) {
|
|
226
|
+
throw new IOError(self.cause);
|
|
227
|
+
}
|
|
228
|
+
return self.value;
|
|
229
|
+
}
|
|
@@ -3,14 +3,14 @@ import { Failure, Success } from "./definition.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* @tsplus static fncts.ExitOps halt
|
|
5
5
|
*/
|
|
6
|
-
export function halt(defect: unknown): Exit<never, never> {
|
|
6
|
+
export function halt(defect: unknown, __tsplusTrace?: string): Exit<never, never> {
|
|
7
7
|
return failCause(Cause.halt(defect));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @tsplus static fncts.ExitOps fail
|
|
12
12
|
*/
|
|
13
|
-
export function fail<E = never, A = never>(e: E): Exit<E, A> {
|
|
13
|
+
export function fail<E = never, A = never>(e: E, __tsplusTrace?: string): Exit<E, A> {
|
|
14
14
|
return failCause(Cause.fail(e));
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -31,22 +31,22 @@ export function fromMaybe<E, A>(fa: Maybe<A>, onNothing: () => E): Exit<E, A> {
|
|
|
31
31
|
/**
|
|
32
32
|
* @tsplus static fncts.ExitOps failCause
|
|
33
33
|
*/
|
|
34
|
-
export function failCause<E = never, A = never>(cause: Cause<E
|
|
35
|
-
return new Failure(cause);
|
|
34
|
+
export function failCause<E = never, A = never>(cause: Cause<E>, __tsplusTrace?: string): Exit<E, A> {
|
|
35
|
+
return new Failure(cause, __tsplusTrace);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @tsplus static fncts.ExitOps interrupt
|
|
40
40
|
*/
|
|
41
|
-
export function interrupt(id: FiberId): Exit<never, never> {
|
|
41
|
+
export function interrupt(id: FiberId, __tsplusTrace?: string): Exit<never, never> {
|
|
42
42
|
return failCause(Cause.interrupt(id));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* @tsplus static fncts.ExitOps succeed
|
|
47
47
|
*/
|
|
48
|
-
export function succeed<E = never, A = never>(value: A): Exit<E, A> {
|
|
49
|
-
return new Success(value);
|
|
48
|
+
export function succeed<E = never, A = never>(value: A, __tsplusTrace?: string): Exit<E, A> {
|
|
49
|
+
return new Success(value, __tsplusTrace);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -23,6 +23,9 @@ export const enum ExitTag {
|
|
|
23
23
|
Failure = "Failure",
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const IOTypeId = Symbol.for("fncts.io.IO");
|
|
27
|
+
type IOTypeId = typeof IOTypeId;
|
|
28
|
+
|
|
26
29
|
const _failureHash = Hashable.string("fncts.Exit.Failure");
|
|
27
30
|
const _successHash = Hashable.string("fncts.Exit.Success");
|
|
28
31
|
|
|
@@ -36,8 +39,9 @@ export class Failure<E> {
|
|
|
36
39
|
readonly _E: (_: never) => E;
|
|
37
40
|
readonly _A: (_: never) => never;
|
|
38
41
|
};
|
|
39
|
-
readonly
|
|
40
|
-
|
|
42
|
+
readonly [IOTypeId]: IOTypeId = IOTypeId;
|
|
43
|
+
readonly _tag = ExitTag.Failure;
|
|
44
|
+
constructor(readonly cause: Cause<E>, readonly trace?: string) {}
|
|
41
45
|
|
|
42
46
|
get [Symbol.hash](): number {
|
|
43
47
|
return Hashable.combine(_failureHash, Hashable.unknown(this.cause));
|
|
@@ -57,8 +61,9 @@ export class Success<A> implements P.Hashable, P.Equatable {
|
|
|
57
61
|
readonly _E: (_: never) => never;
|
|
58
62
|
readonly _A: (_: never) => A;
|
|
59
63
|
};
|
|
60
|
-
readonly
|
|
61
|
-
|
|
64
|
+
readonly [IOTypeId]: IOTypeId = IOTypeId;
|
|
65
|
+
readonly _tag = ExitTag.Success;
|
|
66
|
+
constructor(readonly value: A, readonly trace?: string) {}
|
|
62
67
|
|
|
63
68
|
get [Symbol.hash](): number {
|
|
64
69
|
return Hashable.combine(_successHash, Hashable.unknown(this.value));
|
package/_src/data/FiberId/api.ts
CHANGED
|
@@ -5,20 +5,20 @@ import { Composite, isComposite, isNone } from "./definition.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export function combine(id1: FiberId) {
|
|
7
7
|
return (id0: FiberId): FiberId => {
|
|
8
|
-
if (isNone(
|
|
8
|
+
if (id0.isNone()) {
|
|
9
9
|
return id1;
|
|
10
10
|
}
|
|
11
|
-
if (isNone(
|
|
11
|
+
if (id1.isNone()) {
|
|
12
12
|
return id0;
|
|
13
13
|
}
|
|
14
|
-
if (isComposite(
|
|
15
|
-
if (isComposite(
|
|
14
|
+
if (id0.isComposite()) {
|
|
15
|
+
if (id1.isComposite()) {
|
|
16
16
|
return new Composite(id0.fiberIds.union(id1.fiberIds));
|
|
17
17
|
} else {
|
|
18
18
|
return new Composite(id0.fiberIds.add(id1));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
if (isComposite(
|
|
21
|
+
if (id1.isComposite()) {
|
|
22
22
|
return new Composite(id1.fiberIds.add(id0));
|
|
23
23
|
}
|
|
24
24
|
return new Composite(HashSet.make(id0, id1));
|
|
@@ -4,18 +4,16 @@ import type { Nullable } from "@fncts/base/types";
|
|
|
4
4
|
* @tsplus static fncts.MaybeOps just
|
|
5
5
|
* @tsplus static fncts.JustOps __call
|
|
6
6
|
*/
|
|
7
|
-
export function just<A>(a: A): Maybe<A> {
|
|
8
|
-
return new Just(a);
|
|
7
|
+
export function just<A>(a: A, __tsplusTrace?: string): Maybe<A> {
|
|
8
|
+
return new Just(a, __tsplusTrace);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const _Nothing = new Nothing();
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* @tsplus static fncts.MaybeOps nothing
|
|
15
13
|
* @tsplus static fncts.NothingOps __call
|
|
16
14
|
*/
|
|
17
|
-
export function nothing<A = never>(): Maybe<A> {
|
|
18
|
-
return
|
|
15
|
+
export function nothing<A = never>(__tsplusTrace?: string): Maybe<A> {
|
|
16
|
+
return new Nothing(__tsplusTrace);
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
/**
|
|
@@ -11,6 +11,9 @@ export type MaybeVariance = typeof MaybeVariance;
|
|
|
11
11
|
export const MaybeTypeId = Symbol.for("fncts.Maybe");
|
|
12
12
|
export type MaybeTypeId = typeof MaybeTypeId;
|
|
13
13
|
|
|
14
|
+
const IOTypeId = Symbol.for("fncts.io.IO");
|
|
15
|
+
type IOTypeId = typeof IOTypeId;
|
|
16
|
+
|
|
14
17
|
export interface MaybeF extends HKT {
|
|
15
18
|
type: Maybe<this["A"]>;
|
|
16
19
|
variance: {
|
|
@@ -30,6 +33,8 @@ export abstract class Maybe<A> {
|
|
|
30
33
|
readonly _A: (_: never) => A;
|
|
31
34
|
};
|
|
32
35
|
readonly [MaybeTypeId]: MaybeTypeId = MaybeTypeId;
|
|
36
|
+
readonly [IOTypeId]: IOTypeId = IOTypeId;
|
|
37
|
+
readonly trace?: string | undefined = undefined;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
/**
|
|
@@ -38,7 +43,7 @@ export abstract class Maybe<A> {
|
|
|
38
43
|
*/
|
|
39
44
|
export class Just<A> extends Maybe<A> {
|
|
40
45
|
readonly _tag = MaybeTag.Just;
|
|
41
|
-
constructor(readonly value: A) {
|
|
46
|
+
constructor(readonly value: A, readonly trace?: string) {
|
|
42
47
|
super();
|
|
43
48
|
}
|
|
44
49
|
[Symbol.equals](that: unknown): boolean {
|
|
@@ -55,6 +60,9 @@ export class Just<A> extends Maybe<A> {
|
|
|
55
60
|
*/
|
|
56
61
|
export class Nothing extends Maybe<never> {
|
|
57
62
|
readonly _tag = MaybeTag.Nothing;
|
|
63
|
+
constructor(readonly trace?: string) {
|
|
64
|
+
super();
|
|
65
|
+
}
|
|
58
66
|
[Symbol.equals](that: unknown): boolean {
|
|
59
67
|
return isMaybe(that) && that.isNothing();
|
|
60
68
|
}
|
|
@@ -6,25 +6,43 @@ import { MaybeJson } from "@fncts/base/json/MaybeJson";
|
|
|
6
6
|
import { filter, filterMap, flatMap, foldLeft, foldRight, map, partition, partitionMap, zip, zipWith } from "./api.js";
|
|
7
7
|
import { just } from "./constructors.js";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @tsplus static fncts.MaybeOps Functor
|
|
11
|
+
*/
|
|
9
12
|
export const Functor = HKT.instance<P.Functor<MaybeF>>({ map });
|
|
10
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @tsplus static fncts.MaybeOps Apply
|
|
16
|
+
*/
|
|
11
17
|
export const Apply = HKT.instance<P.Apply<MaybeF>>({ ...Functor, zip, zipWith });
|
|
12
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @tsplus static fncts.MaybeOps Applicative
|
|
21
|
+
*/
|
|
13
22
|
export const Applicative = HKT.instance<P.Applicative<MaybeF>>({
|
|
14
23
|
...Apply,
|
|
15
24
|
pure: just,
|
|
16
25
|
});
|
|
17
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @tsplus static fncts.MaybeOps Monad
|
|
29
|
+
*/
|
|
18
30
|
export const Monad = HKT.instance<P.Monad<MaybeF>>({
|
|
19
31
|
...Applicative,
|
|
20
32
|
flatMap,
|
|
21
33
|
});
|
|
22
34
|
|
|
35
|
+
/**
|
|
36
|
+
* @tsplus static fncts.MaybeOps Foldable
|
|
37
|
+
*/
|
|
23
38
|
export const Foldable = HKT.instance<P.Foldable<MaybeF>>({
|
|
24
39
|
foldLeft,
|
|
25
40
|
foldRight,
|
|
26
41
|
});
|
|
27
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @tsplus static fncts.MaybeOps Filterable
|
|
45
|
+
*/
|
|
28
46
|
export const Filterable = HKT.instance<P.Filterable<MaybeF>>({
|
|
29
47
|
...Functor,
|
|
30
48
|
filter,
|
|
@@ -490,12 +490,12 @@ function reduceToSingleString(
|
|
|
490
490
|
value?: any,
|
|
491
491
|
): string {
|
|
492
492
|
let output = input;
|
|
493
|
-
if (context.compact >= 1) {
|
|
493
|
+
if (Number(context.compact) >= 1) {
|
|
494
494
|
const entries = output.length;
|
|
495
495
|
if (extrasType === ARRAY_EXTRAS_TYPE && entries > 6) {
|
|
496
496
|
output = groupElements(context, output, value);
|
|
497
497
|
}
|
|
498
|
-
if (context.currentDepth - context.recurseTimes < context.compact && entries === output.length) {
|
|
498
|
+
if (context.currentDepth - context.recurseTimes < Number(context.compact) && entries === output.length) {
|
|
499
499
|
const start = output.length + context.indentationLevel + braces[0].length + base.length + 10;
|
|
500
500
|
if (isBelowBreakLength(context, output, start, base)) {
|
|
501
501
|
return `${base ? `${base} ` : ""}${braces[0]} ${output.join(", ")} ${braces[1]}`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const IOErrorTypeId = Symbol.for("fncts.base.exceptions.IOError");
|
|
2
|
+
export type IOErrorTypeId = typeof IOErrorTypeId;
|
|
3
|
+
|
|
4
|
+
export class IOError<E> {
|
|
5
|
+
readonly [IOErrorTypeId]: IOErrorTypeId = IOErrorTypeId;
|
|
6
|
+
constructor(readonly cause: Cause<E>) {}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function isIOError(u: unknown): u is IOError<unknown> {
|
|
10
|
+
return isObject(u) && IOErrorTypeId in u;
|
|
11
|
+
}
|
|
@@ -2,7 +2,7 @@ export const NoSuchElementErrorTag = "NoSuchElementError";
|
|
|
2
2
|
|
|
3
3
|
export class NoSuchElementError extends Error {
|
|
4
4
|
readonly _tag = NoSuchElementErrorTag;
|
|
5
|
-
constructor(message
|
|
5
|
+
constructor(message?: string) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.name = NoSuchElementErrorTag;
|
|
8
8
|
}
|
package/_src/data/exceptions.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./exceptions/IllegalStateError.js";
|
|
|
5
5
|
export * from "./exceptions/IndexOutOfBoundsError.js";
|
|
6
6
|
export * from "./exceptions/InterruptedException.js";
|
|
7
7
|
export * from "./exceptions/InvalidCapacityError.js";
|
|
8
|
+
export * from "./exceptions/IOError.js";
|
|
8
9
|
export * from "./exceptions/NoSuchElementError.js";
|
|
9
10
|
export * from "./exceptions/RuntimeError.js";
|
|
10
11
|
// codegen:end
|
package/_src/data.ts
CHANGED
|
@@ -38,6 +38,7 @@ export type {} from "./data/Predicate.js";
|
|
|
38
38
|
export type {} from "./data/Refinement.js";
|
|
39
39
|
export type {} from "./data/Showable.js";
|
|
40
40
|
export type {} from "./data/string.js";
|
|
41
|
+
export type {} from "./data/Struct.js";
|
|
41
42
|
export type {} from "./data/Tag.js";
|
|
42
43
|
export type {} from "./data/These.js";
|
|
43
44
|
export type {} from "./data/Trace.js";
|
package/_src/typeclass.ts
CHANGED
|
@@ -32,7 +32,7 @@ export * from "./typeclass/WitherableWithIndex.js";
|
|
|
32
32
|
|
|
33
33
|
export { Eq } from "./data/Eq.js";
|
|
34
34
|
export { Equatable } from "./data/Equatable.js";
|
|
35
|
-
export { Guard } from "./data/Guard.js";
|
|
35
|
+
export { Guard } from "./data/Guard/definition.js";
|
|
36
36
|
export { Hash } from "./data/Hash.js";
|
|
37
37
|
export { Hashable } from "./data/Hashable.js";
|
|
38
38
|
export { HashEq } from "./data/HashEq.js";
|
package/_src/types.ts
CHANGED
package/_src/util/predicates.ts
CHANGED
|
@@ -41,6 +41,10 @@ export function isObject<A>(value: A | Primitive): boolean {
|
|
|
41
41
|
return typeof value === "object" && value !== null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export function isRecord(value: unknown): value is object & Record<PropertyKey, unknown> {
|
|
45
|
+
return isObject(value) && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
export function hasTypeId<X extends symbol>(
|
|
45
49
|
value: unknown,
|
|
46
50
|
typeId: X,
|
|
@@ -268,6 +268,11 @@ export declare function reverse<A>(self: Conc<A>): Iterable<A>;
|
|
|
268
268
|
* @tsplus location "@fncts/base/collection/immutable/Conc/api"
|
|
269
269
|
*/
|
|
270
270
|
export declare function separate<E, A>(self: Conc<Either<E, A>>): readonly [Conc<E>, Conc<A>];
|
|
271
|
+
/**
|
|
272
|
+
* @tsplus pipeable fncts.Conc slice
|
|
273
|
+
* @tsplus location "@fncts/base/collection/immutable/Conc/api"
|
|
274
|
+
*/
|
|
275
|
+
export declare function slice(from: number, to: number): <A>(self: import("@fncts/base/collection/immutable/Conc/definition").Conc<A>) => import("@fncts/base/collection/immutable/Conc/definition").Conc<A>;
|
|
271
276
|
/**
|
|
272
277
|
* @tsplus pipeable fncts.Conc splitAt
|
|
273
278
|
* @tsplus location "@fncts/base/collection/immutable/Conc/api"
|
|
@@ -26,6 +26,11 @@ export declare function makeWith<K, V>(config: P.HashEq<K>): HashMap<K, V>;
|
|
|
26
26
|
* @tsplus location "@fncts/base/collection/immutable/HashMap/api"
|
|
27
27
|
*/
|
|
28
28
|
export declare function make<K, V>(...items: ReadonlyArray<readonly [K, V]>): HashMap<K, V>;
|
|
29
|
+
/**
|
|
30
|
+
* @tsplus static fncts.HashMapOps from
|
|
31
|
+
* @tsplus location "@fncts/base/collection/immutable/HashMap/api"
|
|
32
|
+
*/
|
|
33
|
+
export declare function from<K, V>(items: Iterable<readonly [K, V]>): HashMap<K, V>;
|
|
29
34
|
/**
|
|
30
35
|
* Make a new map that has randomly cached hash and structural equality
|
|
31
36
|
* @tsplus static fncts.HashMapOps empty
|
|
@@ -48,7 +48,7 @@ export declare class CollisionNode<K, V> {
|
|
|
48
48
|
constructor(edit: number, hash: number, children: Array<Node<K, V>>);
|
|
49
49
|
modify(edit: number, keyEq: KeyEq<K>, shift: number, f: UpdateFn<V>, hash: number, key: K, size: SizeRef): Node<K, V>;
|
|
50
50
|
}
|
|
51
|
-
declare class IndexedNode<K, V> {
|
|
51
|
+
export declare class IndexedNode<K, V> {
|
|
52
52
|
edit: number;
|
|
53
53
|
mask: number;
|
|
54
54
|
children: Array<Node<K, V>>;
|
|
@@ -64,4 +64,3 @@ export declare class ArrayNode<K, V> {
|
|
|
64
64
|
constructor(edit: number, size: number, children: Array<Node<K, V>>);
|
|
65
65
|
modify(edit: number, keyEq: KeyEq<K>, shift: number, f: UpdateFn<V>, hash: number, key: K, size: SizeRef): Node<K, V>;
|
|
66
66
|
}
|
|
67
|
-
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const ListTypeId: unique symbol;
|
|
2
|
+
export type ListTypeId = typeof ListTypeId;
|
|
1
3
|
/**
|
|
2
4
|
* @tsplus type fncts.List.Cons
|
|
3
5
|
* @tsplus companion fncts.ConsOps
|
|
@@ -6,6 +8,7 @@ export declare class Cons<A> implements Iterable<A> {
|
|
|
6
8
|
readonly head: A;
|
|
7
9
|
tail: List<A>;
|
|
8
10
|
readonly _tag = "Cons";
|
|
11
|
+
readonly [ListTypeId]: ListTypeId;
|
|
9
12
|
constructor(head: A, tail?: List<A>);
|
|
10
13
|
[Symbol.iterator](): Iterator<A>;
|
|
11
14
|
}
|
|
@@ -15,8 +18,14 @@ export declare class Cons<A> implements Iterable<A> {
|
|
|
15
18
|
*/
|
|
16
19
|
export declare class Nil<A> implements Iterable<A> {
|
|
17
20
|
readonly _tag = "Nil";
|
|
21
|
+
readonly [ListTypeId]: ListTypeId;
|
|
18
22
|
[Symbol.iterator](): Iterator<A>;
|
|
19
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @tsplus static fncts.ListOps is
|
|
26
|
+
* @tsplus location "@fncts/base/collection/immutable/List/definition"
|
|
27
|
+
*/
|
|
28
|
+
export declare function isList(u: unknown): u is List<unknown>;
|
|
20
29
|
export declare const _Nil: Nil<never>;
|
|
21
30
|
/**
|
|
22
31
|
* @tsplus type fncts.List
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector } from "@fncts/base/collection/immutable/Vector";
|
|
2
|
-
import { Predicate } from "@fncts/base/data/Predicate/definition";
|
|
3
|
-
import { Refinement } from "@fncts/base/data/Refinement/definition";
|
|
4
2
|
import { Maybe } from "@fncts/base/data/Maybe/definition";
|
|
3
|
+
import { RefinementWithIndex, Refinement } from "@fncts/base/data/Refinement/definition";
|
|
4
|
+
import { PredicateWithIndex, Predicate } from "@fncts/base/data/Predicate/definition";
|
|
5
5
|
import { List } from "@fncts/base/collection/immutable/List/definition";
|
|
6
6
|
import { HKT } from "@fncts/typelevel/HKT";
|
|
7
7
|
import type { MutableVector, VectorF } from "@fncts/base/collection/immutable/Vector/definition";
|
|
@@ -15,6 +15,28 @@ import type * as P from "@fncts/base/typeclass";
|
|
|
15
15
|
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
16
16
|
*/
|
|
17
17
|
export declare function append<A>(a: A): (self: Vector<A>) => Vector<A>;
|
|
18
|
+
/**
|
|
19
|
+
* @tsplus pipeable fncts.Vector filterMapWithIndex
|
|
20
|
+
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
21
|
+
*/
|
|
22
|
+
export declare function filterMapWithIndex<A, B>(f: (i: number, a: A) => Maybe<B>): (self: Vector<A>) => Vector<B>;
|
|
23
|
+
/**
|
|
24
|
+
* @tsplus pipeable fncts.Vector filterMap
|
|
25
|
+
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
26
|
+
*/
|
|
27
|
+
export declare function filterMap<A, B>(f: (a: A) => Maybe<B>): (self: Vector<A>) => Vector<B>;
|
|
28
|
+
/**
|
|
29
|
+
* @tsplus pipeable fncts.Vector filterWithIndex
|
|
30
|
+
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
31
|
+
*/
|
|
32
|
+
export declare function filterWithIndex<A, B extends A>(refinement: RefinementWithIndex<number, A, B>): (self: Vector<A>) => Vector<B>;
|
|
33
|
+
export declare function filterWithIndex<A>(predicate: PredicateWithIndex<number, A>): (self: Vector<A>) => Vector<A>;
|
|
34
|
+
/**
|
|
35
|
+
* @tsplus pipeable fncts.Vector filter
|
|
36
|
+
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
37
|
+
*/
|
|
38
|
+
export declare function filter<A, B extends A>(refinement: Refinement<A, B>): (self: Vector<A>) => Vector<B>;
|
|
39
|
+
export declare function filter<A>(predicate: Predicate<A>): (self: Vector<A>) => Vector<A>;
|
|
18
40
|
/**
|
|
19
41
|
* Maps a function over a Vector and concatenates all the resulting
|
|
20
42
|
* Vectors together.
|
|
@@ -261,6 +283,11 @@ export declare function groupWith<A>(f: (a: A, b: A) => boolean): (self: Vector<
|
|
|
261
283
|
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
262
284
|
*/
|
|
263
285
|
export declare function head<A>(self: Vector<A>): Maybe<NonNullable<A>>;
|
|
286
|
+
/**
|
|
287
|
+
* @tsplus pipeable fncts.Vector includes
|
|
288
|
+
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
289
|
+
*/
|
|
290
|
+
export declare function includes<A>(element: A): (self: Vector<A>) => boolean;
|
|
264
291
|
/**
|
|
265
292
|
* Returns the index of the _first_ element in the Vector that is equal
|
|
266
293
|
* to the given element. If no such element is found `-1` is returned.
|
|
@@ -620,4 +647,4 @@ export declare function updateAt<A>(i: number, a: A): (self: Vector<A>) => Vecto
|
|
|
620
647
|
* @tsplus static fncts.VectorOps __call
|
|
621
648
|
* @tsplus location "@fncts/base/collection/immutable/Vector/api"
|
|
622
649
|
*/
|
|
623
|
-
export declare function vector<A
|
|
650
|
+
export declare function vector<A extends ReadonlyArray<any>>(...elements: A): Vector<[A] extends [ReadonlyArray<infer X>] ? X : never>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tsplus type fncts.CompletablePromise
|
|
3
|
+
* @tsplus companion fncts.CompletablePromiseOps
|
|
4
|
+
*/
|
|
5
|
+
export interface CompletablePromise<A> extends Promise<A> {
|
|
6
|
+
resolve: (a: A) => void;
|
|
7
|
+
reject: (reason: unknown) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @tsplus static fncts.CompletablePromiseOps __call
|
|
11
|
+
* @tsplus location "@fncts/base/control/CompletablePromise"
|
|
12
|
+
*/
|
|
13
|
+
export declare function make<A>(): CompletablePromise<A>;
|
package/control.d.ts
CHANGED