@fncts/base 0.0.6 → 0.0.7
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/traverseConc.cjs +4 -1
- package/_cjs/collection/Iterable/api/traverseConc.cjs.map +1 -1
- package/_cjs/collection/immutable/Dictionary/api.cjs +44 -13
- package/_cjs/collection/immutable/Dictionary/api.cjs.map +1 -1
- package/_cjs/collection/immutable/ImmutableArray/api.cjs +3 -3
- package/_cjs/collection/immutable/ImmutableArray/api.cjs.map +1 -1
- package/_cjs/data/Cause/api.cjs +106 -66
- package/_cjs/data/Cause/api.cjs.map +1 -1
- package/_cjs/data/Either/api.cjs +10 -0
- package/_cjs/data/Either/api.cjs.map +1 -1
- package/_cjs/data/Exit/api.cjs.map +1 -1
- package/_cjs/data/Struct/api.cjs +111 -9
- package/_cjs/data/Struct/api.cjs.map +1 -1
- package/_cjs/data/exceptions/InterruptedException.cjs.map +1 -1
- package/_cjs/optics/Traversal/definition.cjs +12 -14
- package/_cjs/optics/Traversal/definition.cjs.map +1 -1
- package/_cjs/typeclass/Showable/show.cjs +8 -8
- package/_cjs/typeclass/Showable/show.cjs.map +1 -1
- package/_cjs/util/AnsiFormat.cjs +7 -7
- package/_cjs/util/AnsiFormat.cjs.map +1 -1
- package/_mjs/collection/Iterable/api/traverseConc.mjs +4 -1
- package/_mjs/collection/Iterable/api/traverseConc.mjs.map +1 -1
- package/_mjs/collection/immutable/Dictionary/api.mjs +34 -10
- package/_mjs/collection/immutable/Dictionary/api.mjs.map +1 -1
- package/_mjs/collection/immutable/ImmutableArray/api.mjs +3 -3
- package/_mjs/collection/immutable/ImmutableArray/api.mjs.map +1 -1
- package/_mjs/data/Cause/api.mjs +89 -58
- package/_mjs/data/Cause/api.mjs.map +1 -1
- package/_mjs/data/Either/api.mjs +5 -0
- package/_mjs/data/Either/api.mjs.map +1 -1
- package/_mjs/data/Exit/api.mjs.map +1 -1
- package/_mjs/data/Struct/api.mjs +85 -4
- package/_mjs/data/Struct/api.mjs.map +1 -1
- package/_mjs/data/exceptions/InterruptedException.mjs.map +1 -1
- package/_mjs/optics/Traversal/definition.mjs +12 -13
- package/_mjs/optics/Traversal/definition.mjs.map +1 -1
- package/_mjs/typeclass/Showable/show.mjs +8 -8
- package/_mjs/typeclass/Showable/show.mjs.map +1 -1
- package/_mjs/util/AnsiFormat.mjs +7 -7
- package/_mjs/util/AnsiFormat.mjs.map +1 -1
- package/_src/collection/Iterable/api/traverseConc.ts +1 -1
- package/_src/collection/immutable/Dictionary/api.ts +21 -0
- package/_src/data/Cause/api.ts +88 -63
- package/_src/data/Const/instances.ts +1 -1
- package/_src/data/Either/api.ts +5 -0
- package/_src/data/Exit/api.ts +1 -1
- package/_src/data/Struct/api.ts +102 -3
- package/_src/data/exceptions/InterruptedException.ts +1 -1
- package/_src/typeclass/MonadExcept.ts +1 -1
- package/_src/typeclass/Showable/show.ts +4 -3
- package/_src/util/AnsiFormat.ts +5 -5
- package/collection/immutable/Dictionary/api.d.ts +16 -0
- package/data/Cause/api.d.ts +23 -1
- package/data/Either/api.d.ts +6 -0
- package/data/Struct/api.d.ts +58 -2
- package/data/exceptions/InterruptedException.d.ts +2 -2
- package/package.json +1 -1
- package/typeclass/MonadExcept.d.ts +1 -1
package/_src/data/Cause/api.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { EitherTag } from "@fncts/base/data/Either";
|
2
|
+
|
1
3
|
import { Stack } from "../../internal/Stack.js";
|
2
4
|
import { identity } from "../function.js";
|
3
5
|
import { _Empty, Both, Cause, CauseTag, Empty, Fail, Halt, Interrupt, Stackless, Then } from "./definition.js";
|
@@ -55,7 +57,7 @@ export function both<E, E1>(left: Cause<E>, right: Cause<E1>): Cause<E | E1> {
|
|
55
57
|
* @tsplus fluent fncts.Cause flatMap
|
56
58
|
*/
|
57
59
|
export function flatMap_<E, D>(self: Cause<E>, f: (e: E) => Cause<D>): Cause<D> {
|
58
|
-
return
|
60
|
+
return chainEval(self, f).run;
|
59
61
|
}
|
60
62
|
|
61
63
|
/**
|
@@ -64,7 +66,7 @@ export function flatMap_<E, D>(self: Cause<E>, f: (e: E) => Cause<D>): Cause<D>
|
|
64
66
|
* @tsplus fluent fncts.Cause contains
|
65
67
|
*/
|
66
68
|
export function contains_<E, E1 extends E = E>(self: Cause<E>, that: Cause<E1>): boolean {
|
67
|
-
return
|
69
|
+
return containsEval(self, that).run;
|
68
70
|
}
|
69
71
|
|
70
72
|
/**
|
@@ -640,6 +642,15 @@ export function isInterrupt<E>(self: Cause<E>): self is Interrupt {
|
|
640
642
|
return self._tag === CauseTag.Interrupt;
|
641
643
|
}
|
642
644
|
|
645
|
+
/**
|
646
|
+
* Determines if the `Cause` contains an interruption.
|
647
|
+
*
|
648
|
+
* @tsplus getter fncts.Cause isInterrupted
|
649
|
+
*/
|
650
|
+
export function isInterrupted<E>(self: Cause<E>): boolean {
|
651
|
+
return self.find((cause) => (cause.isInterrupt() ? Just(cause) : Nothing())).isJust();
|
652
|
+
}
|
653
|
+
|
643
654
|
/**
|
644
655
|
* A type-guard matching `Traced`
|
645
656
|
*
|
@@ -649,9 +660,9 @@ export function isTraced<E>(self: Cause<E>): boolean {
|
|
649
660
|
return self
|
650
661
|
.find((cause) => {
|
651
662
|
switch (cause._tag) {
|
652
|
-
case
|
653
|
-
case
|
654
|
-
case
|
663
|
+
case CauseTag.Halt:
|
664
|
+
case CauseTag.Fail:
|
665
|
+
case CauseTag.Interrupt:
|
655
666
|
return cause.trace !== Trace.none ? Just(undefined) : Nothing();
|
656
667
|
default:
|
657
668
|
return Nothing();
|
@@ -687,8 +698,10 @@ export function interruptOption<E>(self: Cause<E>): Maybe<FiberId> {
|
|
687
698
|
*
|
688
699
|
* @tsplus getter fncts.Cause interruptors
|
689
700
|
*/
|
690
|
-
export function interruptors<E>(self: Cause<E>):
|
691
|
-
return self.foldLeft(
|
701
|
+
export function interruptors<E>(self: Cause<E>): HashSet<FiberId> {
|
702
|
+
return self.foldLeft(HashSet.makeDefault(), (s, c) =>
|
703
|
+
c._tag === CauseTag.Interrupt ? Just(s.add(c.id)) : Nothing(),
|
704
|
+
);
|
692
705
|
}
|
693
706
|
|
694
707
|
/**
|
@@ -786,6 +799,39 @@ export function stripFailures<A>(self: Cause<A>): Cause<never> {
|
|
786
799
|
});
|
787
800
|
}
|
788
801
|
|
802
|
+
/**
|
803
|
+
* Remove all `Halt` causes that the specified partial function is defined at,
|
804
|
+
* returning `Just` with the remaining causes or `Nothing` if there are no
|
805
|
+
* remaining causes.
|
806
|
+
*
|
807
|
+
* @tsplus fluent fncts.Cause stripSomeDefects
|
808
|
+
*/
|
809
|
+
export function stripSomeDefects<E>(self: Cause<E>, p: Predicate<unknown>): Maybe<Cause<E>> {
|
810
|
+
return self.fold({
|
811
|
+
Empty: () => Just(Empty()),
|
812
|
+
Fail: (e, trace) => Just(Fail(e, trace)),
|
813
|
+
Halt: (t, trace) => (p(t) ? Nothing() : Just(Halt(t, trace))),
|
814
|
+
Interrupt: (fiberId, trace) => Just(Interrupt(fiberId, trace)),
|
815
|
+
Then: (l, r) =>
|
816
|
+
l.isJust() && r.isJust()
|
817
|
+
? Just(Then(l.value, r.value))
|
818
|
+
: l.isJust()
|
819
|
+
? Just(l.value)
|
820
|
+
: r.isJust()
|
821
|
+
? Just(r.value)
|
822
|
+
: Nothing(),
|
823
|
+
Both: (l, r) =>
|
824
|
+
l.isJust() && r.isJust()
|
825
|
+
? Just(Then(l.value, r.value))
|
826
|
+
: l.isJust()
|
827
|
+
? Just(l.value)
|
828
|
+
: r.isJust()
|
829
|
+
? Just(r.value)
|
830
|
+
: Nothing(),
|
831
|
+
Stackless: (causeOption, stackless) => causeOption.map((cause) => Stackless(cause, stackless)),
|
832
|
+
});
|
833
|
+
}
|
834
|
+
|
789
835
|
function sequenceCauseEitherEval<E, A>(self: Cause<Either<E, A>>): Eval<Either<Cause<E>, A>> {
|
790
836
|
switch (self._tag) {
|
791
837
|
case CauseTag.Empty: {
|
@@ -811,8 +857,8 @@ function sequenceCauseEitherEval<E, A>(self: Cause<Either<E, A>>): Eval<Either<C
|
|
811
857
|
(lefts, rights) => {
|
812
858
|
Either.concrete(lefts);
|
813
859
|
Either.concrete(rights);
|
814
|
-
return lefts._tag ===
|
815
|
-
? rights._tag ===
|
860
|
+
return lefts._tag === EitherTag.Left
|
861
|
+
? rights._tag === EitherTag.Right
|
816
862
|
? Either.right(rights.right)
|
817
863
|
: Either.left(Cause.then(lefts.left, rights.left))
|
818
864
|
: Either.right(lefts.right);
|
@@ -825,8 +871,8 @@ function sequenceCauseEitherEval<E, A>(self: Cause<Either<E, A>>): Eval<Either<C
|
|
825
871
|
(lefts, rights) => {
|
826
872
|
Either.concrete(lefts);
|
827
873
|
Either.concrete(rights);
|
828
|
-
return lefts._tag ===
|
829
|
-
? rights._tag ===
|
874
|
+
return lefts._tag === EitherTag.Left
|
875
|
+
? rights._tag === EitherTag.Right
|
830
876
|
? Either.right(rights.right)
|
831
877
|
: Either.left(Cause.both(lefts.left, rights.left))
|
832
878
|
: Either.right(lefts.right);
|
@@ -870,11 +916,11 @@ function sequenceCauseMaybeEval<E>(self: Cause<Maybe<E>>): Eval<Maybe<Cause<E>>>
|
|
870
916
|
(lefts, rights) => {
|
871
917
|
Maybe.concrete(lefts);
|
872
918
|
Maybe.concrete(rights);
|
873
|
-
return lefts._tag ===
|
874
|
-
? rights._tag ===
|
919
|
+
return lefts._tag === MaybeTag.Just
|
920
|
+
? rights._tag === MaybeTag.Just
|
875
921
|
? Maybe.just(Cause.then(lefts.value, rights.value))
|
876
922
|
: lefts
|
877
|
-
: rights._tag ===
|
923
|
+
: rights._tag === MaybeTag.Just
|
878
924
|
? rights
|
879
925
|
: Maybe.nothing();
|
880
926
|
},
|
@@ -886,11 +932,11 @@ function sequenceCauseMaybeEval<E>(self: Cause<Maybe<E>>): Eval<Maybe<Cause<E>>>
|
|
886
932
|
(lefts, rights) => {
|
887
933
|
Maybe.concrete(lefts);
|
888
934
|
Maybe.concrete(rights);
|
889
|
-
return lefts._tag ===
|
890
|
-
? rights._tag ===
|
935
|
+
return lefts._tag === MaybeTag.Just
|
936
|
+
? rights._tag === MaybeTag.Just
|
891
937
|
? Maybe.just(Cause.both(lefts.value, rights.value))
|
892
938
|
: lefts
|
893
|
-
: rights._tag ===
|
939
|
+
: rights._tag === MaybeTag.Just
|
894
940
|
? rights
|
895
941
|
: Maybe.nothing();
|
896
942
|
},
|
@@ -913,52 +959,31 @@ export function sequenceCauseMaybe<E>(self: Cause<Maybe<E>>): Maybe<Cause<E>> {
|
|
913
959
|
return Eval.run(sequenceCauseMaybeEval(self));
|
914
960
|
}
|
915
961
|
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
// /**
|
943
|
-
// * @tsplus getter PCause squash
|
944
|
-
// */
|
945
|
-
// export function squash0<Id, E>(self: Cause<E>) {
|
946
|
-
// return (S: P.Show<Id>) =>
|
947
|
-
// (f: (e: E) => unknown): unknown =>
|
948
|
-
// squash_(S)(self, f);
|
949
|
-
// }
|
950
|
-
|
951
|
-
// /**
|
952
|
-
// * Squashes a `Cause` down to a single `Error`, chosen to be the
|
953
|
-
// * "most important" `Error`.
|
954
|
-
// *
|
955
|
-
// * @dataFirst squash_
|
956
|
-
// */
|
957
|
-
// export function squash<Id>(
|
958
|
-
// S: P.Show<Id>
|
959
|
-
// ): <E>(f: (e: E) => unknown) => (cause: Cause<E>) => unknown {
|
960
|
-
// return (f) => (cause) => squash_(S)(cause, f);
|
961
|
-
// }
|
962
|
+
/**
|
963
|
+
* Squashes a `Cause` down to a single `Error`, chosen to be the
|
964
|
+
* "most important" `Error`.
|
965
|
+
*
|
966
|
+
* @tsplus fluent fncts.Cause squashWith
|
967
|
+
*/
|
968
|
+
export function squashWith_<E>(self: Cause<E>, f: (e: E) => unknown): unknown {
|
969
|
+
return self.failureMaybe
|
970
|
+
.map(f)
|
971
|
+
.orElse(
|
972
|
+
self.isInterrupted
|
973
|
+
? Just(
|
974
|
+
new InterruptedException(
|
975
|
+
"Interrupted by fibers: " +
|
976
|
+
self.interruptors
|
977
|
+
.flatMap((id) => id.ids)
|
978
|
+
.map((id) => `#${id}`)
|
979
|
+
.join(", "),
|
980
|
+
),
|
981
|
+
)
|
982
|
+
: Nothing(),
|
983
|
+
)
|
984
|
+
.orElse(self.defects.head)
|
985
|
+
.getOrElse(new InterruptedException());
|
986
|
+
}
|
962
987
|
|
963
988
|
/**
|
964
989
|
* Constructs a `Cause` from two `Cause`s, representing sequential failures.
|
package/_src/data/Either/api.ts
CHANGED
@@ -140,6 +140,11 @@ export function map_<E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B>
|
|
140
140
|
return self._tag === EitherTag.Left ? self : Right(f(self.right));
|
141
141
|
}
|
142
142
|
|
143
|
+
/**
|
144
|
+
* @tsplus static fncts.EitherOps map
|
145
|
+
*/
|
146
|
+
export const map = Pipeable(map_);
|
147
|
+
|
143
148
|
/**
|
144
149
|
* @tsplus fluent fncts.Either mapLeft
|
145
150
|
*/
|
package/_src/data/Exit/api.ts
CHANGED
@@ -5,7 +5,7 @@ import { ExitTag } from "./definition.js";
|
|
5
5
|
* @tsplus fluent fncts.Exit ap
|
6
6
|
*/
|
7
7
|
export function ap_<E, A, G, B>(fab: Exit<G, (a: A) => B>, fa: Exit<E, A>): Exit<E | G, B> {
|
8
|
-
return
|
8
|
+
return fab.flatMap((f) => fa.map((a) => f(a)));
|
9
9
|
}
|
10
10
|
|
11
11
|
/**
|
package/_src/data/Struct/api.ts
CHANGED
@@ -1,5 +1,97 @@
|
|
1
|
+
import type { Union } from "@fncts/typelevel";
|
2
|
+
|
3
|
+
import { Eq } from "@fncts/base/typeclass";
|
4
|
+
|
1
5
|
import { Struct } from "./definition.js";
|
2
6
|
|
7
|
+
export type EnsureLiteral<N> = string extends N ? never : [N] extends [Union.IntersectionOf<N>] ? N : never;
|
8
|
+
|
9
|
+
export type TestLiteral<N> = string extends N ? unknown : [N] extends [Union.IntersectionOf<N>] ? N : unknown;
|
10
|
+
|
11
|
+
export type EnsureNonexistentProperty<T, N extends string> = Extract<keyof T, N> extends never ? T : never;
|
12
|
+
|
13
|
+
export type EnsureLiteralKeys<O> = string extends keyof O ? never : O;
|
14
|
+
|
15
|
+
export type EnsureLiteralTuple<A extends ReadonlyArray<unknown>> = unknown extends {
|
16
|
+
[K in keyof A]: A[K] extends string ? TestLiteral<A[K]> : unknown;
|
17
|
+
}[number]
|
18
|
+
? never
|
19
|
+
: A;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @tsplus static fncts.StructOps __call
|
23
|
+
* @tsplus macro identity
|
24
|
+
*/
|
25
|
+
export function makeStruct<A>(a: A): Struct<A> {
|
26
|
+
return Struct.get(a);
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @tsplus fluent fncts.Struct set
|
31
|
+
*/
|
32
|
+
export function set_<A, N extends string, B>(
|
33
|
+
self: Struct<A>,
|
34
|
+
key: EnsureLiteral<N>,
|
35
|
+
value: B,
|
36
|
+
): Struct<{ [P in Exclude<keyof A, N> | N]: P extends Exclude<keyof A, N> ? A[P] : B }> {
|
37
|
+
return Struct.get({ ...self.getStruct, [key]: value }) as Struct<any>;
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @tsplus fluent fncts.Struct hmap
|
42
|
+
*/
|
43
|
+
export function hmap_<A extends {}, F extends { [N in keyof A]: (a: A[N]) => any }>(
|
44
|
+
self: Struct<A>,
|
45
|
+
fs: F,
|
46
|
+
): Struct<{ readonly [K in keyof F]: ReturnType<F[K]> }> {
|
47
|
+
const keys = self.keys;
|
48
|
+
const out = {} as any;
|
49
|
+
for (const key of keys) {
|
50
|
+
out[key] = fs[key](unsafeCoerce(self.getStruct[key]));
|
51
|
+
}
|
52
|
+
return out;
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @tsplus fluent fncts.Struct modify
|
57
|
+
*/
|
58
|
+
export function modify_<A, N extends keyof A, B>(
|
59
|
+
self: Struct<A>,
|
60
|
+
key: N,
|
61
|
+
f: (a: A[N]) => B,
|
62
|
+
): Struct<{ readonly [P in Exclude<keyof A, N> | N]: P extends Exclude<keyof A, N> ? A[P] : B }> {
|
63
|
+
return Struct.get({ ...self.getStruct, [key]: f(self.getStruct[key]) }) as Struct<any>;
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @tsplus fluent fncts.Struct pick
|
68
|
+
*/
|
69
|
+
export function pick_<A, N extends ReadonlyArray<keyof A>>(
|
70
|
+
self: Struct<A>,
|
71
|
+
keys: [...N],
|
72
|
+
): Struct<{ readonly [P in N[number]]: A[P] }> {
|
73
|
+
const out = {} as Pick<A, N[number]>;
|
74
|
+
for (const key of keys) {
|
75
|
+
out[key] = self.getStruct[key];
|
76
|
+
}
|
77
|
+
return Struct.get(out);
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @tsplus fluent fncts.Struct omit
|
82
|
+
*/
|
83
|
+
export function omit_<A extends {}, N extends ReadonlyArray<keyof A>>(
|
84
|
+
self: Struct<A>,
|
85
|
+
keys: [...N],
|
86
|
+
): Struct<{ readonly [P in Exclude<keyof A, N[number]>]: A[P] }> {
|
87
|
+
const newKeys = keys.asImmutableArray.difference(self.keys.asImmutableArray, Eq({ equals: (x, y) => x === y }));
|
88
|
+
const out = {} as any;
|
89
|
+
for (const key of newKeys) {
|
90
|
+
out[key] = self.getStruct[key];
|
91
|
+
}
|
92
|
+
return Struct.get(out);
|
93
|
+
}
|
94
|
+
|
3
95
|
/**
|
4
96
|
* @tsplus fluent fncts.Struct map
|
5
97
|
*/
|
@@ -8,15 +100,22 @@ export function map_<A, B>(self: Struct<A>, f: (a: A[keyof A]) => B): Struct<Rec
|
|
8
100
|
const keys = Object.keys(self);
|
9
101
|
for (let i = 0; i < keys.length; i++) {
|
10
102
|
const k = keys[i]! as keyof A;
|
11
|
-
out[k] = f(self.
|
103
|
+
out[k] = f(self.getStruct[k]);
|
12
104
|
}
|
13
105
|
return Struct.get(out);
|
14
106
|
}
|
15
107
|
|
16
108
|
/**
|
17
|
-
* @tsplus getter fncts.Struct
|
109
|
+
* @tsplus getter fncts.Struct keys
|
110
|
+
*/
|
111
|
+
export function keys<A extends {}>(self: Struct<A>): ReadonlyArray<keyof A> {
|
112
|
+
return unsafeCoerce(Object.keys(self.getStruct));
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @tsplus getter fncts.Struct getStruct
|
18
117
|
* @tsplus macro identity
|
19
118
|
*/
|
20
|
-
export function
|
119
|
+
export function getStruct<A>(self: Struct<A>): A {
|
21
120
|
return Struct.reverseGet(self);
|
22
121
|
}
|
@@ -5,7 +5,7 @@ export type InterruptedExceptionTypeId = typeof InterruptedExceptionTypeId;
|
|
5
5
|
|
6
6
|
export class InterruptedException {
|
7
7
|
readonly _typeId: InterruptedExceptionTypeId = InterruptedExceptionTypeId;
|
8
|
-
constructor(readonly message
|
8
|
+
constructor(readonly message?: string) {}
|
9
9
|
}
|
10
10
|
|
11
11
|
export function isInterruptedException(u: unknown): u is InterruptedException {
|
@@ -4,7 +4,7 @@ import type { Monad } from "@fncts/base/typeclass/Monad";
|
|
4
4
|
/**
|
5
5
|
* @tsplus type fncts.MonadExcept
|
6
6
|
*/
|
7
|
-
export interface MonadExcept<F> extends Monad<F>, ApplicativeExcept<F> {}
|
7
|
+
export interface MonadExcept<F extends HKT> extends Monad<F>, ApplicativeExcept<F> {}
|
8
8
|
|
9
9
|
/**
|
10
10
|
* @tsplus type fncts.MonadExceptOps
|
@@ -400,9 +400,9 @@ function showRaw(value: object, typedArray?: string): ShowComputation {
|
|
400
400
|
case "InspectionInfo": {
|
401
401
|
base = Z.succeedNow(info.base);
|
402
402
|
keys = Conc.from(info.keys)
|
403
|
-
.traverse((key) => showProperty(value, key, info.extrasType))
|
403
|
+
.traverse((key) => showProperty(value, key, info.extrasType), Z.Applicative)
|
404
404
|
.crossWith(
|
405
|
-
info.protoProps.traverse((key) => showProperty(value, key, PROTO_TYPE)),
|
405
|
+
info.protoProps.traverse((key) => showProperty(value, key, PROTO_TYPE), Z.Applicative),
|
406
406
|
(k1, k2) => k1.concat(k2),
|
407
407
|
);
|
408
408
|
indices = info.formatter(value);
|
@@ -546,6 +546,7 @@ function showMap(value: Map<unknown, unknown>): ShowComputationChunk {
|
|
546
546
|
.apSecond(
|
547
547
|
(value as Iterable<[unknown, unknown]>).traverseToConc(([k, v]) =>
|
548
548
|
_show(k).crossWith(_show(v), (k, v) => `${k} => ${v}`),
|
549
|
+
Z.Applicative
|
549
550
|
),
|
550
551
|
)
|
551
552
|
.apFirst(
|
@@ -577,7 +578,7 @@ function showTypedArray(value: TypedArray): ShowComputationChunk {
|
|
577
578
|
.apSecond(
|
578
579
|
Z.succeedNow(output).flatMap((output) =>
|
579
580
|
Conc("BYTES_PER_ELEMENT", "length", "byteLength", "byteOffset", "buffer")
|
580
|
-
.traverse((key) => _show(value[key as keyof TypedArray]).map((shown) => `[${key}]: ${shown}`))
|
581
|
+
.traverse((key) => _show(value[key as keyof TypedArray]).map((shown) => `[${key}]: ${shown}`), Z.Applicative)
|
581
582
|
.map((shownKeys) => output.concat(shownKeys)),
|
582
583
|
),
|
583
584
|
)
|
package/_src/util/AnsiFormat.ts
CHANGED
@@ -246,11 +246,11 @@ function generateStyles() {
|
|
246
246
|
}));
|
247
247
|
|
248
248
|
return {
|
249
|
-
...Struct
|
250
|
-
...Struct
|
251
|
-
...Struct
|
252
|
-
...Struct
|
253
|
-
...Struct
|
249
|
+
...Struct(modifiers).map(([open, close]) => style(open, close)).getStruct,
|
250
|
+
...Struct(colors).map(([open, close]) => style(open, close)).getStruct,
|
251
|
+
...Struct(colorsBright).map(([open, close]) => style(open, close)).getStruct,
|
252
|
+
...Struct(colorsBg).map(([open, close]) => style(open, close)).getStruct,
|
253
|
+
...Struct(colorsBrightBg).map(([open, close]) => style(open, close)).getStruct,
|
254
254
|
};
|
255
255
|
}
|
256
256
|
|
@@ -1,9 +1,20 @@
|
|
1
1
|
import { Dictionary } from "@fncts/base/collection/immutable/Dictionary/definition";
|
2
|
+
import { Maybe } from "@fncts/base/data/Maybe/definition";
|
3
|
+
/**
|
4
|
+
* @tsplus fluent fncts.Dictionary foldLeft
|
5
|
+
* @tsplus location "@fncts/base/collection/immutable/Dictionary/api"
|
6
|
+
*/
|
7
|
+
export declare function foldLeft_<A, B>(self: Dictionary<A>, b: B, f: (b: B, a: A) => B): B;
|
2
8
|
/**
|
3
9
|
* @tsplus fluent fncts.Dictionary foldLeftWithIndex
|
4
10
|
* @tsplus location "@fncts/base/collection/immutable/Dictionary/api"
|
5
11
|
*/
|
6
12
|
export declare function foldLeftWithIndex_<A, B>(self: Dictionary<A>, b: B, f: (k: string, b: B, a: A) => B): B;
|
13
|
+
/**
|
14
|
+
* @tsplus fluent fncts.Dictionary get
|
15
|
+
* @tsplus location "@fncts/base/collection/immutable/Dictionary/api"
|
16
|
+
*/
|
17
|
+
export declare function get_<A>(self: Dictionary<A>, key: string): Maybe<A>;
|
7
18
|
/**
|
8
19
|
* @tsplus getter fncts.Dictionary keys
|
9
20
|
* @tsplus location "@fncts/base/collection/immutable/Dictionary/api"
|
@@ -25,3 +36,8 @@ export declare function mapWithIndex_<A, B>(self: Dictionary<A>, f: (k: string,
|
|
25
36
|
* @tsplus location "@fncts/base/collection/immutable/Dictionary/api"
|
26
37
|
*/
|
27
38
|
export declare function toRecord<A>(self: Dictionary<A>): Record<string, A>;
|
39
|
+
/**
|
40
|
+
* @tsplus fluent fncts.Dictionary unsafeGet
|
41
|
+
* @tsplus location "@fncts/base/collection/immutable/Dictionary/api"
|
42
|
+
*/
|
43
|
+
export declare function unsafeGet_<A>(self: Dictionary<A>, key: string): A | undefined;
|
package/data/Cause/api.d.ts
CHANGED
@@ -6,6 +6,7 @@ import { Either } from "@fncts/base/data/Either/definition";
|
|
6
6
|
import { Maybe } from "@fncts/base/data/Maybe/definition";
|
7
7
|
import { Predicate } from "@fncts/base/data/Predicate/definition";
|
8
8
|
import { FiberId } from "@fncts/base/data/FiberId/definition";
|
9
|
+
import { HashSet } from "@fncts/base/collection/immutable/HashSet/definition";
|
9
10
|
import { Both, Cause, Fail, Halt, Interrupt, Then } from "./definition.js";
|
10
11
|
/**
|
11
12
|
* @tsplus fluent fncts.Cause as
|
@@ -187,6 +188,12 @@ export declare function isThen<E>(self: Cause<E>): self is Then<E>;
|
|
187
188
|
* @tsplus location "@fncts/base/data/Cause/api"
|
188
189
|
*/
|
189
190
|
export declare function isInterrupt<E>(self: Cause<E>): self is Interrupt;
|
191
|
+
/**
|
192
|
+
* Determines if the `Cause` contains an interruption.
|
193
|
+
* @tsplus getter fncts.Cause isInterrupted
|
194
|
+
* @tsplus location "@fncts/base/data/Cause/api"
|
195
|
+
*/
|
196
|
+
export declare function isInterrupted<E>(self: Cause<E>): boolean;
|
190
197
|
/**
|
191
198
|
* A type-guard matching `Traced`
|
192
199
|
* @tsplus getter fncts.Cause isTraced
|
@@ -211,7 +218,7 @@ export declare function interruptOption<E>(self: Cause<E>): Maybe<FiberId>;
|
|
211
218
|
* @tsplus getter fncts.Cause interruptors
|
212
219
|
* @tsplus location "@fncts/base/data/Cause/api"
|
213
220
|
*/
|
214
|
-
export declare function interruptors<E>(self: Cause<E>):
|
221
|
+
export declare function interruptors<E>(self: Cause<E>): HashSet<FiberId>;
|
215
222
|
/**
|
216
223
|
* Determines if the `Cause` contains only interruptions and not any `Halt` or
|
217
224
|
* `Fail` causes.
|
@@ -248,6 +255,14 @@ export declare function stackless<E>(cause: Cause<E>, stackless: boolean): Cause
|
|
248
255
|
* @tsplus location "@fncts/base/data/Cause/api"
|
249
256
|
*/
|
250
257
|
export declare function stripFailures<A>(self: Cause<A>): Cause<never>;
|
258
|
+
/**
|
259
|
+
* Remove all `Halt` causes that the specified partial function is defined at,
|
260
|
+
* returning `Just` with the remaining causes or `Nothing` if there are no
|
261
|
+
* remaining causes.
|
262
|
+
* @tsplus fluent fncts.Cause stripSomeDefects
|
263
|
+
* @tsplus location "@fncts/base/data/Cause/api"
|
264
|
+
*/
|
265
|
+
export declare function stripSomeDefects<E>(self: Cause<E>, p: Predicate<unknown>): Maybe<Cause<E>>;
|
251
266
|
/**
|
252
267
|
* Converts the specified `Cause<Either<E, A>>` to an `Either<Cause<E>, A>`.
|
253
268
|
* @tsplus getter fncts.Cause sequenceCauseEither
|
@@ -260,6 +275,13 @@ export declare function sequenceCauseEither<E, A>(self: Cause<Either<E, A>>): Ei
|
|
260
275
|
* @tsplus location "@fncts/base/data/Cause/api"
|
261
276
|
*/
|
262
277
|
export declare function sequenceCauseMaybe<E>(self: Cause<Maybe<E>>): Maybe<Cause<E>>;
|
278
|
+
/**
|
279
|
+
* Squashes a `Cause` down to a single `Error`, chosen to be the
|
280
|
+
* "most important" `Error`.
|
281
|
+
* @tsplus fluent fncts.Cause squashWith
|
282
|
+
* @tsplus location "@fncts/base/data/Cause/api"
|
283
|
+
*/
|
284
|
+
export declare function squashWith_<E>(self: Cause<E>, f: (e: E) => unknown): unknown;
|
263
285
|
/**
|
264
286
|
* Constructs a `Cause` from two `Cause`s, representing sequential failures.
|
265
287
|
* @note If one of the `Cause`s is `Empty`, the non-empty `Cause` is returned
|
package/data/Either/api.d.ts
CHANGED
@@ -87,6 +87,12 @@ export declare function isRight<E, A>(self: Either<E, A>): self is Right<A>;
|
|
87
87
|
* @tsplus location "@fncts/base/data/Either/api"
|
88
88
|
*/
|
89
89
|
export declare function map_<E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B>;
|
90
|
+
/**
|
91
|
+
* @tsplus static fncts.EitherOps map
|
92
|
+
* @tsplus pipeable fncts.Either map
|
93
|
+
* @tsplus location "@fncts/base/data/Either/api"
|
94
|
+
*/
|
95
|
+
export declare const map: <A, B>(f: (a: A) => B) => <E>(self: import("./definition.js").Either<E, A>) => import("./definition.js").Either<E, B>;
|
90
96
|
/**
|
91
97
|
* @tsplus fluent fncts.Either mapLeft
|
92
98
|
* @tsplus location "@fncts/base/data/Either/api"
|
package/data/Struct/api.d.ts
CHANGED
@@ -1,12 +1,68 @@
|
|
1
|
+
import type { Union } from "@fncts/typelevel";
|
1
2
|
import { Struct } from "./definition.js";
|
3
|
+
export declare type EnsureLiteral<N> = string extends N ? never : [N] extends [Union.IntersectionOf<N>] ? N : never;
|
4
|
+
export declare type TestLiteral<N> = string extends N ? unknown : [N] extends [Union.IntersectionOf<N>] ? N : unknown;
|
5
|
+
export declare type EnsureNonexistentProperty<T, N extends string> = Extract<keyof T, N> extends never ? T : never;
|
6
|
+
export declare type EnsureLiteralKeys<O> = string extends keyof O ? never : O;
|
7
|
+
export declare type EnsureLiteralTuple<A extends ReadonlyArray<unknown>> = unknown extends {
|
8
|
+
[K in keyof A]: A[K] extends string ? TestLiteral<A[K]> : unknown;
|
9
|
+
}[number] ? never : A;
|
10
|
+
/**
|
11
|
+
* @tsplus static fncts.StructOps __call
|
12
|
+
* @tsplus macro identity
|
13
|
+
* @tsplus location "@fncts/base/data/Struct/api"
|
14
|
+
*/
|
15
|
+
export declare function makeStruct<A>(a: A): Struct<A>;
|
16
|
+
/**
|
17
|
+
* @tsplus fluent fncts.Struct set
|
18
|
+
* @tsplus location "@fncts/base/data/Struct/api"
|
19
|
+
*/
|
20
|
+
export declare function set_<A, N extends string, B>(self: Struct<A>, key: EnsureLiteral<N>, value: B): Struct<{
|
21
|
+
[P in Exclude<keyof A, N> | N]: P extends Exclude<keyof A, N> ? A[P] : B;
|
22
|
+
}>;
|
23
|
+
/**
|
24
|
+
* @tsplus fluent fncts.Struct hmap
|
25
|
+
* @tsplus location "@fncts/base/data/Struct/api"
|
26
|
+
*/
|
27
|
+
export declare function hmap_<A extends {}, F extends {
|
28
|
+
[N in keyof A]: (a: A[N]) => any;
|
29
|
+
}>(self: Struct<A>, fs: F): Struct<{
|
30
|
+
readonly [K in keyof F]: ReturnType<F[K]>;
|
31
|
+
}>;
|
32
|
+
/**
|
33
|
+
* @tsplus fluent fncts.Struct modify
|
34
|
+
* @tsplus location "@fncts/base/data/Struct/api"
|
35
|
+
*/
|
36
|
+
export declare function modify_<A, N extends keyof A, B>(self: Struct<A>, key: N, f: (a: A[N]) => B): Struct<{
|
37
|
+
readonly [P in Exclude<keyof A, N> | N]: P extends Exclude<keyof A, N> ? A[P] : B;
|
38
|
+
}>;
|
39
|
+
/**
|
40
|
+
* @tsplus fluent fncts.Struct pick
|
41
|
+
* @tsplus location "@fncts/base/data/Struct/api"
|
42
|
+
*/
|
43
|
+
export declare function pick_<A, N extends ReadonlyArray<keyof A>>(self: Struct<A>, keys: [...N]): Struct<{
|
44
|
+
readonly [P in N[number]]: A[P];
|
45
|
+
}>;
|
46
|
+
/**
|
47
|
+
* @tsplus fluent fncts.Struct omit
|
48
|
+
* @tsplus location "@fncts/base/data/Struct/api"
|
49
|
+
*/
|
50
|
+
export declare function omit_<A extends {}, N extends ReadonlyArray<keyof A>>(self: Struct<A>, keys: [...N]): Struct<{
|
51
|
+
readonly [P in Exclude<keyof A, N[number]>]: A[P];
|
52
|
+
}>;
|
2
53
|
/**
|
3
54
|
* @tsplus fluent fncts.Struct map
|
4
55
|
* @tsplus location "@fncts/base/data/Struct/api"
|
5
56
|
*/
|
6
57
|
export declare function map_<A, B>(self: Struct<A>, f: (a: A[keyof A]) => B): Struct<Record<keyof A, B>>;
|
7
58
|
/**
|
8
|
-
* @tsplus getter fncts.Struct
|
59
|
+
* @tsplus getter fncts.Struct keys
|
60
|
+
* @tsplus location "@fncts/base/data/Struct/api"
|
61
|
+
*/
|
62
|
+
export declare function keys<A extends {}>(self: Struct<A>): ReadonlyArray<keyof A>;
|
63
|
+
/**
|
64
|
+
* @tsplus getter fncts.Struct getStruct
|
9
65
|
* @tsplus macro identity
|
10
66
|
* @tsplus location "@fncts/base/data/Struct/api"
|
11
67
|
*/
|
12
|
-
export declare function
|
68
|
+
export declare function getStruct<A>(self: Struct<A>): A;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
export declare const InterruptedExceptionTypeId: unique symbol;
|
2
2
|
export declare type InterruptedExceptionTypeId = typeof InterruptedExceptionTypeId;
|
3
3
|
export declare class InterruptedException {
|
4
|
-
readonly message
|
4
|
+
readonly message?: string | undefined;
|
5
5
|
readonly _typeId: InterruptedExceptionTypeId;
|
6
|
-
constructor(message
|
6
|
+
constructor(message?: string | undefined);
|
7
7
|
}
|
8
8
|
export declare function isInterruptedException(u: unknown): u is InterruptedException;
|
package/package.json
CHANGED
@@ -5,7 +5,7 @@ import type { Monad } from "@fncts/base/typeclass/Monad";
|
|
5
5
|
/**
|
6
6
|
* @tsplus type fncts.MonadExcept
|
7
7
|
*/
|
8
|
-
export interface MonadExcept<F> extends Monad<F>, ApplicativeExcept<F> {
|
8
|
+
export interface MonadExcept<F extends HKT> extends Monad<F>, ApplicativeExcept<F> {
|
9
9
|
}
|
10
10
|
/**
|
11
11
|
* @tsplus type fncts.MonadExceptOps
|