@fncts/base 0.0.22 → 0.0.24
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/immutable/Conc/definition.cjs +6 -5
- package/_cjs/collection/immutable/Conc/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/definition.cjs +9 -6
- package/_cjs/collection/immutable/HashMap/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/HashSet/api.cjs +15 -1
- package/_cjs/collection/immutable/HashSet/api.cjs.map +1 -1
- package/_cjs/collection/immutable/HashSet/definition.cjs +9 -6
- package/_cjs/collection/immutable/HashSet/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/ImmutableArray/definition.cjs +7 -4
- package/_cjs/collection/immutable/ImmutableArray/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/RoseTree/definition.cjs +7 -4
- package/_cjs/collection/immutable/RoseTree/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/SortedMap/definition.cjs +3 -2
- package/_cjs/collection/immutable/SortedMap/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/Vector/definition.cjs +7 -4
- package/_cjs/collection/immutable/Vector/definition.cjs.map +1 -1
- package/_cjs/control/Eval/definition.cjs +11 -5
- package/_cjs/control/Eval/definition.cjs.map +1 -1
- package/_cjs/control/Z/definition.cjs +16 -9
- package/_cjs/control/Z/definition.cjs.map +1 -1
- package/_cjs/data/CaseClass.cjs +3 -2
- package/_cjs/data/CaseClass.cjs.map +1 -1
- package/_cjs/data/Cause/api.cjs +26 -1
- package/_cjs/data/Cause/api.cjs.map +1 -1
- package/_cjs/data/Cause/definition.cjs +3 -1
- package/_cjs/data/Cause/definition.cjs.map +1 -1
- package/_cjs/data/Datum/definition.cjs +10 -9
- package/_cjs/data/Datum/definition.cjs.map +1 -1
- package/_cjs/data/DatumEither/definition.cjs.map +1 -1
- package/_cjs/data/DatumEither.cjs +28 -0
- package/_cjs/data/DatumEither.cjs.map +1 -0
- package/_cjs/data/DecodeError/definition.cjs +3 -1
- package/_cjs/data/DecodeError/definition.cjs.map +1 -1
- package/_cjs/data/Decoder/definition.cjs +4 -2
- package/_cjs/data/Decoder/definition.cjs.map +1 -1
- package/_cjs/data/Duration/definition.cjs +5 -4
- package/_cjs/data/Duration/definition.cjs.map +1 -1
- package/_cjs/data/Either/api.cjs +6 -6
- package/_cjs/data/Either/api.cjs.map +1 -1
- package/_cjs/data/Either/definition.cjs +7 -3
- package/_cjs/data/Either/definition.cjs.map +1 -1
- package/_cjs/data/Encoder/definition.cjs +3 -1
- package/_cjs/data/Encoder/definition.cjs.map +1 -1
- package/_cjs/data/Environment/api.cjs +5 -15
- package/_cjs/data/Environment/api.cjs.map +1 -1
- package/_cjs/data/Environment/definition.cjs +9 -10
- package/_cjs/data/Environment/definition.cjs.map +1 -1
- package/_cjs/data/EnvironmentPatch.cjs +6 -2
- package/_cjs/data/EnvironmentPatch.cjs.map +1 -1
- package/_cjs/data/Exit/definition.cjs +12 -9
- package/_cjs/data/Exit/definition.cjs.map +1 -1
- package/_cjs/data/FiberId/definition.cjs +9 -8
- package/_cjs/data/FiberId/definition.cjs.map +1 -1
- package/_cjs/data/Guard/definition.cjs +7 -3
- package/_cjs/data/Guard/definition.cjs.map +1 -1
- package/_cjs/data/Maybe/definition.cjs +8 -4
- package/_cjs/data/Maybe/definition.cjs.map +1 -1
- package/_cjs/data/Showable/show.cjs +1 -1
- package/_cjs/data/Showable/show.cjs.map +1 -1
- package/_cjs/data/Struct.cjs +28 -0
- package/_cjs/data/Struct.cjs.map +1 -0
- package/_cjs/data/Tag/definition.cjs +7 -4
- package/_cjs/data/Tag/definition.cjs.map +1 -1
- package/_cjs/data/These/definition.cjs +10 -6
- package/_cjs/data/These/definition.cjs.map +1 -1
- package/_cjs/data/exceptions/InterruptedException.cjs +7 -3
- package/_cjs/data/exceptions/InterruptedException.cjs.map +1 -1
- package/_cjs/util/predicates.cjs +1 -1
- package/_cjs/util/predicates.cjs.map +1 -1
- package/_mjs/collection/immutable/Conc/definition.mjs +6 -5
- package/_mjs/collection/immutable/Conc/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/HashMap/definition.mjs +6 -4
- package/_mjs/collection/immutable/HashMap/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/HashSet/api.mjs +12 -0
- package/_mjs/collection/immutable/HashSet/api.mjs.map +1 -1
- package/_mjs/collection/immutable/HashSet/definition.mjs +6 -4
- package/_mjs/collection/immutable/HashSet/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/ImmutableArray/definition.mjs +5 -3
- package/_mjs/collection/immutable/ImmutableArray/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/RoseTree/definition.mjs +5 -3
- package/_mjs/collection/immutable/RoseTree/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/SortedMap/definition.mjs +3 -2
- package/_mjs/collection/immutable/SortedMap/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/Vector/definition.mjs +5 -3
- package/_mjs/collection/immutable/Vector/definition.mjs.map +1 -1
- package/_mjs/control/Eval/definition.mjs +9 -3
- package/_mjs/control/Eval/definition.mjs.map +1 -1
- package/_mjs/control/Z/definition.mjs +11 -7
- package/_mjs/control/Z/definition.mjs.map +1 -1
- package/_mjs/data/CaseClass.mjs +3 -2
- package/_mjs/data/CaseClass.mjs.map +1 -1
- package/_mjs/data/Cause/api.mjs +22 -0
- package/_mjs/data/Cause/api.mjs.map +1 -1
- package/_mjs/data/Cause/definition.mjs +1 -0
- package/_mjs/data/Cause/definition.mjs.map +1 -1
- package/_mjs/data/Datum/definition.mjs +10 -9
- package/_mjs/data/Datum/definition.mjs.map +1 -1
- package/_mjs/data/DatumEither/definition.mjs.map +1 -1
- package/_mjs/data/DatumEither.mjs +4 -0
- package/_mjs/data/DatumEither.mjs.map +1 -0
- package/_mjs/data/DecodeError/definition.mjs +3 -1
- package/_mjs/data/DecodeError/definition.mjs.map +1 -1
- package/_mjs/data/Decoder/definition.mjs +3 -1
- package/_mjs/data/Decoder/definition.mjs.map +1 -1
- package/_mjs/data/Duration/definition.mjs +5 -4
- package/_mjs/data/Duration/definition.mjs.map +1 -1
- package/_mjs/data/Either/api.mjs +6 -6
- package/_mjs/data/Either/api.mjs.map +1 -1
- package/_mjs/data/Either/definition.mjs +4 -1
- package/_mjs/data/Either/definition.mjs.map +1 -1
- package/_mjs/data/Encoder/definition.mjs +3 -1
- package/_mjs/data/Encoder/definition.mjs.map +1 -1
- package/_mjs/data/Environment/api.mjs +4 -12
- package/_mjs/data/Environment/api.mjs.map +1 -1
- package/_mjs/data/Environment/definition.mjs +6 -8
- package/_mjs/data/Environment/definition.mjs.map +1 -1
- package/_mjs/data/EnvironmentPatch.mjs +4 -1
- package/_mjs/data/EnvironmentPatch.mjs.map +1 -1
- package/_mjs/data/Exit/definition.mjs +10 -8
- package/_mjs/data/Exit/definition.mjs.map +1 -1
- package/_mjs/data/FiberId/definition.mjs +9 -8
- package/_mjs/data/FiberId/definition.mjs.map +1 -1
- package/_mjs/data/Guard/definition.mjs +4 -1
- package/_mjs/data/Guard/definition.mjs.map +1 -1
- package/_mjs/data/Maybe/definition.mjs +5 -2
- package/_mjs/data/Maybe/definition.mjs.map +1 -1
- package/_mjs/data/Showable/show.mjs +1 -1
- package/_mjs/data/Showable/show.mjs.map +1 -1
- package/_mjs/data/Struct.mjs +4 -0
- package/_mjs/data/Struct.mjs.map +1 -0
- package/_mjs/data/Tag/definition.mjs +5 -3
- package/_mjs/data/Tag/definition.mjs.map +1 -1
- package/_mjs/data/These/definition.mjs +10 -4
- package/_mjs/data/These/definition.mjs.map +1 -1
- package/_mjs/data/exceptions/InterruptedException.mjs +5 -3
- package/_mjs/data/exceptions/InterruptedException.mjs.map +1 -1
- package/_mjs/util/predicates.mjs +1 -1
- package/_mjs/util/predicates.mjs.map +1 -1
- package/_src/collection/immutable/Conc/definition.ts +3 -3
- package/_src/collection/immutable/HashMap/definition.ts +12 -7
- package/_src/collection/immutable/HashSet/api.ts +13 -0
- package/_src/collection/immutable/HashSet/definition.ts +11 -5
- package/_src/collection/immutable/ImmutableArray/definition.ts +8 -3
- package/_src/collection/immutable/RoseTree/definition.ts +8 -3
- package/_src/collection/immutable/SortedMap/definition.ts +1 -1
- package/_src/collection/immutable/Vector/definition.ts +12 -5
- package/_src/control/Eval/definition.ts +22 -10
- package/_src/control/Z/definition.ts +17 -14
- package/_src/data/CaseClass.ts +3 -2
- package/_src/data/Cause/api.ts +24 -0
- package/_src/data/Cause/definition.ts +25 -15
- package/_src/data/Datum/definition.ts +8 -7
- package/_src/data/DatumEither/definition.ts +0 -1
- package/_src/data/DatumEither.ts +4 -0
- package/_src/data/DecodeError/definition.ts +1 -1
- package/_src/data/Decoder/definition.ts +1 -1
- package/_src/data/Duration/definition.ts +2 -4
- package/_src/data/Either/api.ts +1 -3
- package/_src/data/Either/definition.ts +8 -3
- package/_src/data/Encoder/definition.ts +1 -1
- package/_src/data/Environment/api.ts +0 -11
- package/_src/data/Environment/definition.ts +9 -8
- package/_src/data/EnvironmentPatch.ts +8 -3
- package/_src/data/Exit/definition.ts +16 -12
- package/_src/data/FiberId/definition.ts +7 -9
- package/_src/data/Guard/definition.ts +7 -2
- package/_src/data/Maybe/definition.ts +11 -18
- package/_src/data/Showable/show.ts +1 -1
- package/_src/data/Struct.ts +4 -0
- package/_src/data/Tag/definition.ts +7 -4
- package/_src/data/These/definition.ts +7 -7
- package/_src/data/exceptions/InterruptedException.ts +2 -4
- package/_src/data.ts +1 -0
- package/_src/util/predicates.ts +2 -2
- package/collection/immutable/Conc/definition.d.ts +2 -2
- package/collection/immutable/HashMap/definition.d.ts +10 -6
- package/collection/immutable/HashSet/api.d.ts +5 -0
- package/collection/immutable/HashSet/definition.d.ts +9 -4
- package/collection/immutable/ImmutableArray/definition.d.ts +6 -2
- package/collection/immutable/RoseTree/definition.d.ts +6 -2
- package/collection/immutable/SortedMap/definition.d.ts +1 -1
- package/collection/immutable/Vector/definition.d.ts +10 -4
- package/control/Eval/definition.d.ts +18 -7
- package/control/Z/definition.d.ts +12 -8
- package/data/Cause/api.d.ts +12 -0
- package/data/Cause/definition.d.ts +23 -7
- package/data/Datum/definition.d.ts +4 -3
- package/data/DatumEither/definition.d.ts +0 -1
- package/data/DatumEither.d.ts +2 -0
- package/data/DecodeError/definition.d.ts +1 -1
- package/data/Decoder/definition.d.ts +1 -1
- package/data/Duration/definition.d.ts +1 -1
- package/data/Either/definition.d.ts +7 -3
- package/data/EitherT/api.d.ts +2 -2
- package/data/Encoder/definition.d.ts +1 -1
- package/data/Environment/api.d.ts +0 -5
- package/data/Environment/definition.d.ts +8 -8
- package/data/EnvironmentPatch.d.ts +7 -3
- package/data/Exit/definition.d.ts +12 -6
- package/data/FiberId/definition.d.ts +3 -3
- package/data/Guard/definition.d.ts +6 -2
- package/data/Maybe/definition.d.ts +13 -11
- package/data/Struct.d.ts +2 -0
- package/data/Tag/definition.d.ts +6 -2
- package/data/These/definition.d.ts +3 -3
- package/data/exceptions/InterruptedException.d.ts +1 -1
- package/data.d.ts +1 -0
- package/package.json +1 -1
- package/util/predicates.d.ts +1 -1
|
@@ -34,6 +34,7 @@ const initialHash = Hashable.combine(datumHash, Hashable.string(DatumTag.Ini
|
|
|
34
34
|
*/
|
|
35
35
|
export class Initial implements Hashable, Equatable {
|
|
36
36
|
readonly _tag = DatumTag.Initial;
|
|
37
|
+
readonly [DatumTypeId]: DatumTypeId = DatumTypeId;
|
|
37
38
|
get [Symbol.hash](): number {
|
|
38
39
|
return initialHash;
|
|
39
40
|
}
|
|
@@ -49,8 +50,8 @@ const pendingHash = Hashable.combine(datumHash, Hashable.string(DatumTag.Pending
|
|
|
49
50
|
* @tsplus companion fncts.Datum.PendingOps
|
|
50
51
|
*/
|
|
51
52
|
export class Pending implements Hashable, Equatable {
|
|
52
|
-
readonly
|
|
53
|
-
readonly _tag
|
|
53
|
+
readonly [DatumTypeId]: DatumTypeId = DatumTypeId;
|
|
54
|
+
readonly _tag = DatumTag.Pending;
|
|
54
55
|
get [Symbol.hash](): number {
|
|
55
56
|
return pendingHash;
|
|
56
57
|
}
|
|
@@ -64,8 +65,8 @@ export class Pending implements Hashable, Equatable {
|
|
|
64
65
|
* @tsplus companion fncts.Datum.RefreshOps
|
|
65
66
|
*/
|
|
66
67
|
export class Refresh<A> implements Hashable, Equatable {
|
|
67
|
-
readonly
|
|
68
|
-
readonly _tag
|
|
68
|
+
readonly [DatumTypeId]: DatumTypeId = DatumTypeId;
|
|
69
|
+
readonly _tag = DatumTag.Refresh;
|
|
69
70
|
constructor(readonly value: A) {}
|
|
70
71
|
get [Symbol.hash](): number {
|
|
71
72
|
return Hashable.combine(Hashable.combine(datumHash, Hashable.string(this._tag)), Hashable.unknown(this.value));
|
|
@@ -80,8 +81,8 @@ export class Refresh<A> implements Hashable, Equatable {
|
|
|
80
81
|
* @tsplus companion fncts.Datum.RepleteOps
|
|
81
82
|
*/
|
|
82
83
|
export class Replete<A> implements Hashable, Equatable {
|
|
83
|
-
readonly
|
|
84
|
-
readonly _tag
|
|
84
|
+
readonly [DatumTypeId]: DatumTypeId = DatumTypeId;
|
|
85
|
+
readonly _tag = DatumTag.Replete;
|
|
85
86
|
constructor(readonly value: A) {}
|
|
86
87
|
get [Symbol.hash](): number {
|
|
87
88
|
return Hashable.combine(Hashable.combine(datumHash, Hashable.string(this._tag)), Hashable.unknown(this.value));
|
|
@@ -95,5 +96,5 @@ export class Replete<A> implements Hashable, Equatable {
|
|
|
95
96
|
* @tsplus static fncts.DatumOps is
|
|
96
97
|
*/
|
|
97
98
|
export function isDatum(u: unknown): u is Datum<unknown> {
|
|
98
|
-
return
|
|
99
|
+
return isObject(u) && DatumTypeId in u;
|
|
99
100
|
}
|
|
@@ -6,7 +6,7 @@ export const DecodeErrorTypeId = Symbol.for("fncts.DecodeError");
|
|
|
6
6
|
export type DecodeErrorTypeId = typeof DecodeErrorTypeId;
|
|
7
7
|
|
|
8
8
|
export abstract class DecodeError {
|
|
9
|
-
readonly
|
|
9
|
+
readonly [DecodeErrorTypeId]: DecodeErrorTypeId = DecodeErrorTypeId;
|
|
10
10
|
abstract render: Eval<RoseTree<string>>;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ export interface DecoderF extends HKT {
|
|
|
16
16
|
* @tsplus derive nominal
|
|
17
17
|
*/
|
|
18
18
|
export class Decoder<in out A> {
|
|
19
|
-
readonly
|
|
19
|
+
readonly [DecoderTypeId]: DecoderTypeId = DecoderTypeId;
|
|
20
20
|
constructor(readonly decode: (input: unknown) => These<DecodeError, A>, readonly label: string) {}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { hasTypeId } from "../../util/predicates.js";
|
|
2
|
-
|
|
3
1
|
export const DurationTypeId = Symbol.for("fncts.Duration");
|
|
4
2
|
export type DurationTypeId = typeof DurationTypeId;
|
|
5
3
|
|
|
@@ -8,7 +6,7 @@ export type DurationTypeId = typeof DurationTypeId;
|
|
|
8
6
|
* @tsplus companion fncts.DurationOps
|
|
9
7
|
*/
|
|
10
8
|
export class Duration implements Equatable, Hashable {
|
|
11
|
-
readonly
|
|
9
|
+
readonly [DurationTypeId]: DurationTypeId = DurationTypeId;
|
|
12
10
|
constructor(readonly milliseconds: number) {}
|
|
13
11
|
|
|
14
12
|
[Symbol.equals](that: unknown): boolean {
|
|
@@ -21,5 +19,5 @@ export class Duration implements Equatable, Hashable {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
export function isDuration(u: unknown): u is Duration {
|
|
24
|
-
return
|
|
22
|
+
return isObject(u) && DurationTypeId in u;
|
|
25
23
|
}
|
package/_src/data/Either/api.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type * as P from "../../typeclass.js";
|
|
2
2
|
import type { EitherF } from "./definition.js";
|
|
3
3
|
|
|
4
|
-
import { hasTypeId } from "../../util/predicates.js";
|
|
5
4
|
import { identity } from "../function.js";
|
|
6
|
-
import { concrete } from "./definition.js";
|
|
7
5
|
import { EitherTag, EitherTypeId, Left, Right } from "./definition.js";
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -128,7 +126,7 @@ export function getOrElse<E, B>(orElse: (e: E) => B) {
|
|
|
128
126
|
* @tsplus static fncts.EitherOps isEither
|
|
129
127
|
*/
|
|
130
128
|
export function isEither(u: unknown): u is Either<unknown, unknown> {
|
|
131
|
-
return
|
|
129
|
+
return isObject(u) && EitherTypeId in u;
|
|
132
130
|
}
|
|
133
131
|
|
|
134
132
|
/**
|
|
@@ -3,6 +3,9 @@ export const enum EitherTag {
|
|
|
3
3
|
Right = "Right",
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
export const EitherVariance = Symbol.for("fncts.Either.Variance");
|
|
7
|
+
export type EitherVariance = typeof EitherVariance;
|
|
8
|
+
|
|
6
9
|
export const EitherTypeId = Symbol.for("fncts.data.Either");
|
|
7
10
|
export type EitherTypeId = typeof EitherTypeId;
|
|
8
11
|
|
|
@@ -19,9 +22,11 @@ export interface EitherF extends HKT {
|
|
|
19
22
|
* @tsplus companion fncts.EitherOps
|
|
20
23
|
*/
|
|
21
24
|
export class Either<E, A> {
|
|
22
|
-
readonly
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
readonly [EitherTypeId]: EitherTypeId = EitherTypeId;
|
|
26
|
+
declare [EitherVariance]: {
|
|
27
|
+
readonly _E: (_: never) => E;
|
|
28
|
+
readonly _A: (_: never) => A;
|
|
29
|
+
};
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
/**
|
|
@@ -7,7 +7,7 @@ export type EncoderTypeId = typeof EncoderTypeId;
|
|
|
7
7
|
* @tsplus derive nominal
|
|
8
8
|
*/
|
|
9
9
|
export class Encoder<in out A> {
|
|
10
|
-
readonly
|
|
10
|
+
readonly [EncoderTypeId]: EncoderTypeId = EncoderTypeId;
|
|
11
11
|
constructor(readonly encode: (inp: A) => unknown) {}
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -49,17 +49,6 @@ export function union<R1>(that: Environment<R1>) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* @tsplus getter fncts.Environment clean
|
|
54
|
-
*/
|
|
55
|
-
export function clean<R>(self: Environment<R>): Environment<R> {
|
|
56
|
-
const [map, index] = self.map.toList.foldLeft(
|
|
57
|
-
[HashMap.empty<Tag<unknown>, readonly [unknown, number]>(), 0],
|
|
58
|
-
([map, index], [tag, service]) => [map.set(tag, [service, index] as const), index + 1],
|
|
59
|
-
);
|
|
60
|
-
return new Environment(map);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
52
|
/**
|
|
64
53
|
* @tsplus pipeable fncts.Environment unsafeGet
|
|
65
54
|
*/
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { EnvironmentPatch } from "@fncts/base/data/EnvironmentPatch";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export const EnvSymbol = Symbol.for("fncts.Env");
|
|
3
|
+
export const EnvironmentVariance = Symbol.for("fncts.Environment.Variance");
|
|
4
|
+
export type EnvironmentVariance = typeof EnvironmentVariance;
|
|
7
5
|
|
|
8
|
-
export
|
|
6
|
+
export const EnvironmentTypeId = Symbol.for("fncts.Environment");
|
|
7
|
+
export type EnvironmentTypeId = typeof EnvironmentTypeId;
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* @tsplus type fncts.Environment
|
|
12
11
|
* @tsplus companion fncts.EnvironmentOps
|
|
13
12
|
*/
|
|
14
13
|
export class Environment<R> implements Hashable, Equatable {
|
|
15
|
-
readonly
|
|
16
|
-
|
|
14
|
+
readonly [EnvironmentTypeId]: EnvironmentTypeId = EnvironmentTypeId;
|
|
15
|
+
declare [EnvironmentVariance]: {
|
|
16
|
+
_R: (_: never) => R;
|
|
17
|
+
};
|
|
17
18
|
constructor(readonly map: HashMap<Tag<any>, unknown>, public cache: HashMap<Tag<any>, unknown> = HashMap.empty()) {}
|
|
18
19
|
|
|
19
20
|
get [Symbol.hash](): number {
|
|
@@ -30,5 +31,5 @@ export declare namespace Environment {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export function isEnvironment(u: unknown): u is Environment<unknown> {
|
|
33
|
-
return
|
|
34
|
+
return isObject(u) && EnvironmentTypeId in u;
|
|
34
35
|
}
|
|
@@ -6,6 +6,9 @@ export const enum EnvironmentPatchTag {
|
|
|
6
6
|
Empty,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
export const EnvironmentPatchVariance = Symbol.for("fncts.Environment.Patch.Variance");
|
|
10
|
+
export type EnvironmentPatchVariance = typeof EnvironmentPatchVariance;
|
|
11
|
+
|
|
9
12
|
export const EnvironmentPatchTypeId = Symbol.for("fncts.Environment.Patch");
|
|
10
13
|
export type EnvironmentPatchTypeId = typeof EnvironmentPatchTypeId;
|
|
11
14
|
|
|
@@ -14,9 +17,11 @@ export type EnvironmentPatchTypeId = typeof EnvironmentPatchTypeId;
|
|
|
14
17
|
* @tsplus companion fncts.Environment.PatchOps
|
|
15
18
|
*/
|
|
16
19
|
export abstract class EnvironmentPatch<In, Out> {
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
readonly [EnvironmentPatchTypeId]: EnvironmentPatchTypeId = EnvironmentPatchTypeId;
|
|
21
|
+
declare [EnvironmentPatchVariance]: {
|
|
22
|
+
readonly _R: (_: In) => void;
|
|
23
|
+
readonly _A: (_: never) => Out;
|
|
24
|
+
};
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export class AddService<Env, Service> extends EnvironmentPatch<Env, Env & Has<Service>> {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as P from "../../typeclass.js";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
export const ExitVariance = Symbol.for("fncts.Exit");
|
|
4
|
+
export type ExitVariance = typeof ExitVariance;
|
|
3
5
|
|
|
4
6
|
export const ExitTypeId = Symbol.for("fncts.Exit");
|
|
5
7
|
export type ExitTypeId = typeof ExitTypeId;
|
|
@@ -29,11 +31,12 @@ const _successHash = Hashable.string("fncts.Exit.Success");
|
|
|
29
31
|
* @tsplus companion fncts.Exit.FailureOps
|
|
30
32
|
*/
|
|
31
33
|
export class Failure<E> {
|
|
32
|
-
readonly
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
readonly [ExitTypeId]: ExitTypeId = ExitTypeId;
|
|
35
|
+
declare [ExitVariance]: {
|
|
36
|
+
readonly _E: (_: never) => E;
|
|
37
|
+
readonly _A: (_: never) => never;
|
|
38
|
+
};
|
|
39
|
+
readonly _tag = ExitTag.Failure;
|
|
37
40
|
constructor(readonly cause: Cause<E>) {}
|
|
38
41
|
|
|
39
42
|
get [Symbol.hash](): number {
|
|
@@ -49,11 +52,12 @@ export class Failure<E> {
|
|
|
49
52
|
* @tsplus companion fncts.Exit.SuccessOps
|
|
50
53
|
*/
|
|
51
54
|
export class Success<A> implements P.Hashable, P.Equatable {
|
|
52
|
-
readonly
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
readonly [ExitTypeId]: ExitTypeId = ExitTypeId;
|
|
56
|
+
declare [ExitVariance]: {
|
|
57
|
+
readonly _E: (_: never) => never;
|
|
58
|
+
readonly _A: (_: never) => A;
|
|
59
|
+
};
|
|
60
|
+
readonly _tag = ExitTag.Success;
|
|
57
61
|
constructor(readonly value: A) {}
|
|
58
62
|
|
|
59
63
|
get [Symbol.hash](): number {
|
|
@@ -68,7 +72,7 @@ export class Success<A> implements P.Hashable, P.Equatable {
|
|
|
68
72
|
* @tsplus static fncts.ExitOps isExit
|
|
69
73
|
*/
|
|
70
74
|
export function isExit(u: unknown): u is Exit<unknown, unknown> {
|
|
71
|
-
return
|
|
75
|
+
return isObject(u) && ExitTypeId in u;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
/**
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { hasTypeId } from "../../util/predicates.js";
|
|
2
|
-
|
|
3
1
|
export const FiberIdTypeId = Symbol.for("fncts.FiberId");
|
|
4
2
|
export type FiberIdTypeId = typeof FiberIdTypeId;
|
|
5
3
|
|
|
6
4
|
const _hashNone = Hashable.string("fncts.FiberId.None");
|
|
7
5
|
|
|
8
6
|
export class None implements Hashable, Equatable {
|
|
9
|
-
readonly
|
|
10
|
-
readonly _tag
|
|
7
|
+
readonly [FiberIdTypeId]: FiberIdTypeId = FiberIdTypeId;
|
|
8
|
+
readonly _tag = "None";
|
|
11
9
|
[Symbol.equals](that: unknown) {
|
|
12
10
|
return isFiberId(that) && isNone(that);
|
|
13
11
|
}
|
|
@@ -19,8 +17,8 @@ export class None implements Hashable, Equatable {
|
|
|
19
17
|
const _hashRuntime = Hashable.string("fncts.FiberId.Runtime");
|
|
20
18
|
|
|
21
19
|
export class Runtime implements Hashable, Equatable {
|
|
22
|
-
readonly
|
|
23
|
-
readonly _tag
|
|
20
|
+
readonly [FiberIdTypeId]: FiberIdTypeId = FiberIdTypeId;
|
|
21
|
+
readonly _tag = "Runtime";
|
|
24
22
|
constructor(readonly id: number, readonly startTime: number, readonly location?: string) {}
|
|
25
23
|
get [Symbol.hash]() {
|
|
26
24
|
return Hashable.combine(Hashable.combine(_hashRuntime, Hashable.number(this.id)), Hashable.unknown(this.location));
|
|
@@ -33,8 +31,8 @@ export class Runtime implements Hashable, Equatable {
|
|
|
33
31
|
const _hashComposite = Hashable.string("fncts.FiberId.Composite");
|
|
34
32
|
|
|
35
33
|
export class Composite implements Hashable, Equatable {
|
|
36
|
-
readonly
|
|
37
|
-
readonly _tag
|
|
34
|
+
readonly [FiberIdTypeId]: FiberIdTypeId = FiberIdTypeId;
|
|
35
|
+
readonly _tag = "Composite";
|
|
38
36
|
constructor(readonly fiberIds: HashSet<Runtime>) {}
|
|
39
37
|
[Symbol.equals](that: unknown) {
|
|
40
38
|
return isFiberId(that) && isComposite(that) && this.fiberIds == that.fiberIds;
|
|
@@ -66,7 +64,7 @@ export declare namespace FiberId {
|
|
|
66
64
|
* @tsplus static fncts.FiberIdOps isFiberId
|
|
67
65
|
*/
|
|
68
66
|
export function isFiberId(u: unknown): u is FiberId {
|
|
69
|
-
return
|
|
67
|
+
return isObject(u) && FiberIdTypeId in u;
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
/**
|
|
@@ -2,6 +2,9 @@ export interface GuardF extends HKT {
|
|
|
2
2
|
readonly type: Guard<this["A"]>;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
export const GuardVariance = Symbol.for("fncts.Guard.Variance");
|
|
6
|
+
export type GuardVariance = typeof GuardVariance;
|
|
7
|
+
|
|
5
8
|
export const GuardTypeId = Symbol.for("fncts.Guard");
|
|
6
9
|
export type GuardTypeId = typeof GuardTypeId;
|
|
7
10
|
|
|
@@ -10,8 +13,10 @@ export type GuardTypeId = typeof GuardTypeId;
|
|
|
10
13
|
* @tsplus companion fncts.GuardOps
|
|
11
14
|
*/
|
|
12
15
|
export class Guard<A> {
|
|
13
|
-
readonly
|
|
14
|
-
declare
|
|
16
|
+
readonly [GuardTypeId]: GuardTypeId = GuardTypeId;
|
|
17
|
+
declare [GuardVariance]: {
|
|
18
|
+
readonly _A: (_: never) => A;
|
|
19
|
+
};
|
|
15
20
|
constructor(readonly is: Refinement<unknown, A>) {}
|
|
16
21
|
}
|
|
17
22
|
|
|
@@ -5,8 +5,11 @@ export const enum MaybeTag {
|
|
|
5
5
|
Nothing = "Nothing",
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export const MaybeVariance = Symbol.for("fncts.Maybe.Variance");
|
|
9
|
+
export type MaybeVariance = typeof MaybeVariance;
|
|
10
|
+
|
|
8
11
|
export const MaybeTypeId = Symbol.for("fncts.Maybe");
|
|
9
|
-
export type
|
|
12
|
+
export type MaybeTypeId = typeof MaybeTypeId;
|
|
10
13
|
|
|
11
14
|
export interface MaybeF extends HKT {
|
|
12
15
|
type: Maybe<this["A"]>;
|
|
@@ -22,9 +25,11 @@ const _nothingHash = Hashable.string("fncts.Nothing");
|
|
|
22
25
|
* @tsplus type fncts.Maybe
|
|
23
26
|
* @tsplus companion fncts.MaybeOps
|
|
24
27
|
*/
|
|
25
|
-
export class Maybe<A> {
|
|
26
|
-
declare
|
|
27
|
-
|
|
28
|
+
export abstract class Maybe<A> {
|
|
29
|
+
declare [MaybeVariance]: {
|
|
30
|
+
readonly _A: (_: never) => A;
|
|
31
|
+
};
|
|
32
|
+
readonly [MaybeTypeId]: MaybeTypeId = MaybeTypeId;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
/**
|
|
@@ -63,15 +68,7 @@ export class Nothing extends Maybe<never> {
|
|
|
63
68
|
*/
|
|
64
69
|
export function unifyMaybe<X extends Maybe<any>>(
|
|
65
70
|
self: X,
|
|
66
|
-
): Maybe<
|
|
67
|
-
[X] extends [
|
|
68
|
-
{
|
|
69
|
-
_A: () => infer A;
|
|
70
|
-
},
|
|
71
|
-
]
|
|
72
|
-
? A
|
|
73
|
-
: never
|
|
74
|
-
> {
|
|
71
|
+
): Maybe<[X] extends [{ [MaybeVariance]: { _A: (_: never) => infer A } }] ? A : never> {
|
|
75
72
|
return self;
|
|
76
73
|
}
|
|
77
74
|
|
|
@@ -79,11 +76,7 @@ export function unifyMaybe<X extends Maybe<any>>(
|
|
|
79
76
|
* @tsplus static fncts.MaybeOps isMaybe
|
|
80
77
|
*/
|
|
81
78
|
export function isMaybe(u: unknown): u is Maybe<unknown> {
|
|
82
|
-
return (
|
|
83
|
-
isObject(u) &&
|
|
84
|
-
(MaybeTypeId in u ||
|
|
85
|
-
("_tag" in u && typeof u["_tag"] === "string" && (u["_tag"] === "Nothing" || u["_tag"] === "Just")))
|
|
86
|
-
);
|
|
79
|
+
return isObject(u) && MaybeTypeId in u;
|
|
87
80
|
}
|
|
88
81
|
|
|
89
82
|
/**
|
|
@@ -874,7 +874,7 @@ function _showString(context: ShowContext, value: string): string {
|
|
|
874
874
|
) {
|
|
875
875
|
return (
|
|
876
876
|
result
|
|
877
|
-
.split(/(
|
|
877
|
+
.split(/(?<=\n)/)
|
|
878
878
|
.map((line) => context.stylize(strEscape(line), "string"))
|
|
879
879
|
.join(` +\n${" ".repeat(context.indentationLevel + 2)}`) + trailer
|
|
880
880
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export const TagVariance = Symbol.for("fncts.Tag.Variance");
|
|
2
|
+
export type TagVariance = typeof TagVariance;
|
|
2
3
|
|
|
3
4
|
export const TagTypeId = Symbol.for("fncts.Tag");
|
|
4
5
|
export type TagTypeId = typeof TagTypeId;
|
|
@@ -12,8 +13,10 @@ const _tagHash = Hashable.string("fncts.Tag");
|
|
|
12
13
|
* @tsplus companion fncts.TagOps
|
|
13
14
|
*/
|
|
14
15
|
export class Tag<in out T> implements Hashable, Equatable {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
readonly [TagTypeId]: TagTypeId = TagTypeId;
|
|
17
|
+
declare [TagVariance]: {
|
|
18
|
+
readonly _T: (_: T) => T;
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
constructor(readonly id: string) {}
|
|
19
22
|
|
|
@@ -27,5 +30,5 @@ export class Tag<in out T> implements Hashable, Equatable {
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
export function isTag(u: unknown): u is Tag<unknown> {
|
|
30
|
-
return
|
|
33
|
+
return isObject(u) && TagTypeId in u;
|
|
31
34
|
}
|
|
@@ -11,8 +11,8 @@ export type TheseTypeId = typeof TheseTypeId;
|
|
|
11
11
|
* @tsplus type fncts.These.Left
|
|
12
12
|
*/
|
|
13
13
|
export class Left<E> {
|
|
14
|
-
readonly
|
|
15
|
-
readonly _tag
|
|
14
|
+
readonly [TheseTypeId]: TheseTypeId = TheseTypeId;
|
|
15
|
+
readonly _tag = TheseTag.Left;
|
|
16
16
|
constructor(readonly left: E) {}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -20,8 +20,8 @@ export class Left<E> {
|
|
|
20
20
|
* @tsplus type fncts.These.Right
|
|
21
21
|
*/
|
|
22
22
|
export class Right<A> {
|
|
23
|
-
readonly
|
|
24
|
-
readonly _tag
|
|
23
|
+
readonly [TheseTypeId]: TheseTypeId = TheseTypeId;
|
|
24
|
+
readonly _tag = TheseTag.Right;
|
|
25
25
|
constructor(readonly right: A) {}
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -29,8 +29,8 @@ export class Right<A> {
|
|
|
29
29
|
* @tsplus type fncts.These.Both
|
|
30
30
|
*/
|
|
31
31
|
export class Both<E, A> {
|
|
32
|
-
readonly
|
|
33
|
-
readonly _tag
|
|
32
|
+
readonly [TheseTypeId]: TheseTypeId = TheseTypeId;
|
|
33
|
+
readonly _tag = TheseTag.Both;
|
|
34
34
|
constructor(readonly left: E, readonly right: A) {}
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -50,5 +50,5 @@ export const These: TheseOps = {};
|
|
|
50
50
|
* @tsplus static fncts.TheseOps isThese
|
|
51
51
|
*/
|
|
52
52
|
export function isThese(u: unknown): u is These<unknown, unknown> {
|
|
53
|
-
return
|
|
53
|
+
return isObject(u) && TheseTypeId in u;
|
|
54
54
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { hasTypeId } from "../../util/predicates.js";
|
|
2
|
-
|
|
3
1
|
export const InterruptedExceptionTypeId = Symbol.for("fncts.InterruptedException");
|
|
4
2
|
export type InterruptedExceptionTypeId = typeof InterruptedExceptionTypeId;
|
|
5
3
|
|
|
6
4
|
export class InterruptedException {
|
|
7
|
-
readonly
|
|
5
|
+
readonly [InterruptedExceptionTypeId]: InterruptedExceptionTypeId = InterruptedExceptionTypeId;
|
|
8
6
|
constructor(readonly message?: string) {}
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
export function isInterruptedException(u: unknown): u is InterruptedException {
|
|
12
|
-
return
|
|
10
|
+
return isObject(u) && InterruptedExceptionTypeId in u;
|
|
13
11
|
}
|
package/_src/data.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type {} from "./data/Byte.js";
|
|
|
6
6
|
export type {} from "./data/CaseClass.js";
|
|
7
7
|
export type {} from "./data/Cause.js";
|
|
8
8
|
export type {} from "./data/Const.js";
|
|
9
|
+
export type {} from "./data/DatumEither.js";
|
|
9
10
|
export type {} from "./data/DecodeError.js";
|
|
10
11
|
export type {} from "./data/Decoder.js";
|
|
11
12
|
export type {} from "./data/Duration.js";
|
package/_src/util/predicates.ts
CHANGED
|
@@ -45,9 +45,9 @@ export function hasTypeId<X extends symbol>(
|
|
|
45
45
|
value: unknown,
|
|
46
46
|
typeId: X,
|
|
47
47
|
): value is {
|
|
48
|
-
readonly
|
|
48
|
+
readonly [K in X]: X;
|
|
49
49
|
} & Record<PropertyKey, unknown> {
|
|
50
|
-
return isObject(value) &&
|
|
50
|
+
return isObject(value) && typeId in value;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export function isFunction(value: unknown): value is Function {
|
|
@@ -32,14 +32,14 @@ export interface ConcF extends HKT {
|
|
|
32
32
|
*/
|
|
33
33
|
export declare abstract class Conc<A> implements Iterable<A>, Hashable, Equatable {
|
|
34
34
|
_A: () => A;
|
|
35
|
-
readonly
|
|
35
|
+
readonly [ConcTypeId]: ConcTypeId;
|
|
36
36
|
abstract readonly length: number;
|
|
37
37
|
abstract [Symbol.iterator](): Iterator<A>;
|
|
38
38
|
get [Symbol.hash](): number;
|
|
39
39
|
[Symbol.equals](that: unknown): boolean;
|
|
40
40
|
}
|
|
41
41
|
declare abstract class ConcImplementation<A> implements Iterable<A> {
|
|
42
|
-
readonly
|
|
42
|
+
readonly [ConcTypeId]: ConcTypeId;
|
|
43
43
|
_A: () => A;
|
|
44
44
|
get [Symbol.hash](): number;
|
|
45
45
|
[Symbol.equals](that: unknown): boolean;
|
|
@@ -12,21 +12,25 @@ export interface HashMapF extends HKT {
|
|
|
12
12
|
};
|
|
13
13
|
index: this["K"];
|
|
14
14
|
}
|
|
15
|
-
export declare const
|
|
16
|
-
export type
|
|
15
|
+
export declare const HashMapVariance: unique symbol;
|
|
16
|
+
export type HashMapVariance = typeof HashMapVariance;
|
|
17
|
+
export declare const HashMapTypeId: unique symbol;
|
|
18
|
+
export type HashMapTypeId = typeof HashMapTypeId;
|
|
17
19
|
/**
|
|
18
20
|
* @tsplus type fncts.HashMap
|
|
19
21
|
* @tsplus companion fncts.HashMapOps
|
|
20
22
|
*/
|
|
21
|
-
export declare class HashMap<K, V> implements Iterable<readonly [K, V]>, Hashable, Equatable {
|
|
23
|
+
export declare class HashMap<in out K, in out V> implements Iterable<readonly [K, V]>, Hashable, Equatable {
|
|
22
24
|
editable: boolean;
|
|
23
25
|
edit: number;
|
|
24
26
|
readonly config: HashEq<K>;
|
|
25
27
|
root: Node<K, V>;
|
|
26
28
|
size: number;
|
|
27
|
-
readonly
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
readonly [HashMapTypeId]: HashMapTypeId;
|
|
30
|
+
[HashMapVariance]: {
|
|
31
|
+
readonly _K: (_: K) => K;
|
|
32
|
+
readonly _A: (_: V) => V;
|
|
33
|
+
};
|
|
30
34
|
constructor(editable: boolean, edit: number, config: HashEq<K>, root: Node<K, V>, size: number);
|
|
31
35
|
[Symbol.iterator](): Iterator<readonly [K, V]>;
|
|
32
36
|
get [Symbol.hash](): number;
|
|
@@ -59,6 +59,11 @@ export declare function mutate<A>(transient: (set: HashSet<A>) => void): (self:
|
|
|
59
59
|
* @tsplus location "@fncts/base/collection/immutable/HashSet/api"
|
|
60
60
|
*/
|
|
61
61
|
export declare function remove<A>(value: A): (self: HashSet<A>) => HashSet<A>;
|
|
62
|
+
/**
|
|
63
|
+
* @tsplus pipeable fncts.HashSet removeMany
|
|
64
|
+
* @tsplus location "@fncts/base/collection/immutable/HashSet/api"
|
|
65
|
+
*/
|
|
66
|
+
export declare function removeMany<A>(values: Iterable<A>): (self: HashSet<A>) => HashSet<A>;
|
|
62
67
|
/**
|
|
63
68
|
* Calculate the number of keys pairs in a set
|
|
64
69
|
* @tsplus getter fncts.HashSet size
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Hashable } from "@fncts/base/data/Hashable";
|
|
2
2
|
import * as P from "@fncts/base/typeclass";
|
|
3
|
-
export declare const
|
|
4
|
-
export type
|
|
3
|
+
export declare const HashSetVariance: unique symbol;
|
|
4
|
+
export type HashSetVariance = typeof HashSetVariance;
|
|
5
|
+
export declare const HashSetTypeId: unique symbol;
|
|
6
|
+
export type HashSetTypeId = typeof HashSetTypeId;
|
|
5
7
|
/**
|
|
6
8
|
* @tsplus type fncts.HashSet
|
|
7
9
|
* @tsplus companion fncts.HashSetOps
|
|
8
10
|
*/
|
|
9
|
-
export declare class HashSet<A> implements Iterable<A>, P.Hashable, P.Equatable {
|
|
11
|
+
export declare class HashSet<in out A> implements Iterable<A>, P.Hashable, P.Equatable {
|
|
10
12
|
/**
|
|
11
13
|
* @internal
|
|
12
14
|
*/
|
|
@@ -27,7 +29,10 @@ export declare class HashSet<A> implements Iterable<A>, P.Hashable, P.Equatable
|
|
|
27
29
|
* @internal
|
|
28
30
|
*/
|
|
29
31
|
_size: number;
|
|
30
|
-
readonly
|
|
32
|
+
readonly [HashSetTypeId]: HashSetTypeId;
|
|
33
|
+
[HashSetVariance]: {
|
|
34
|
+
readonly _A: (_: A) => A;
|
|
35
|
+
};
|
|
31
36
|
constructor(
|
|
32
37
|
/**
|
|
33
38
|
* @internal
|