@fncts/base 0.0.34 → 0.0.35
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/api.cjs +1 -4
- package/_cjs/collection/immutable/Conc/api.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/api.cjs +4 -7
- package/_cjs/collection/immutable/HashMap/api.cjs.map +1 -1
- package/_cjs/collection/immutable/HashSet/api.cjs +4 -7
- package/_cjs/collection/immutable/HashSet/api.cjs.map +1 -1
- package/_cjs/collection/immutable/ImmutableArray/api.cjs +6 -9
- package/_cjs/collection/immutable/ImmutableArray/api.cjs.map +1 -1
- package/_cjs/collection/immutable/ImmutableArray/instances.cjs.map +1 -1
- package/_cjs/control/Pure/api.cjs +8 -20
- package/_cjs/control/Pure/api.cjs.map +1 -1
- package/_cjs/data/Cause/api.cjs +2 -8
- package/_cjs/data/Cause/api.cjs.map +1 -1
- package/_cjs/data/Datum/api.cjs +2 -8
- package/_cjs/data/Datum/api.cjs.map +1 -1
- package/_cjs/data/DatumEither/api.cjs +2 -8
- package/_cjs/data/DatumEither/api.cjs.map +1 -1
- package/_cjs/data/Either/api.cjs +6 -24
- package/_cjs/data/Either/api.cjs.map +1 -1
- package/_cjs/data/Either/destructors.cjs +3 -3
- package/_cjs/data/Either/destructors.cjs.map +1 -1
- package/_cjs/data/Either/instances.cjs +7 -27
- package/_cjs/data/Either/instances.cjs.map +1 -1
- package/_cjs/data/EitherT/api.cjs +2 -8
- package/_cjs/data/EitherT/api.cjs.map +1 -1
- package/_cjs/data/Exit/constructors.cjs +1 -4
- package/_cjs/data/Exit/constructors.cjs.map +1 -1
- package/_cjs/data/Guard/api.cjs +4 -2
- package/_cjs/data/Guard/api.cjs.map +1 -1
- package/_cjs/data/Maybe/api.cjs +1 -4
- package/_cjs/data/Maybe/api.cjs.map +1 -1
- package/_cjs/data/Maybe/instances.cjs +13 -46
- package/_cjs/data/Maybe/instances.cjs.map +1 -1
- package/_cjs/data/Showable/show.cjs.map +1 -1
- package/_cjs/data/These/instances.cjs +0 -11
- package/_cjs/data/These/instances.cjs.map +1 -1
- package/_cjs/json/EitherJson.cjs +0 -18
- package/_cjs/json/EitherJson.cjs.map +1 -1
- package/_cjs/json/MaybeJson.cjs +0 -16
- package/_cjs/json/MaybeJson.cjs.map +1 -1
- package/_cjs/json/TheseJson.cjs +0 -22
- package/_cjs/json/TheseJson.cjs.map +1 -1
- package/_cjs/optics/Optional/definition.cjs +1 -4
- package/_cjs/optics/Optional/definition.cjs.map +1 -1
- package/_cjs/optics/Prism/definition.cjs +1 -4
- package/_cjs/optics/Prism/definition.cjs.map +1 -1
- package/_cjs/typeclass/MonadExcept.cjs +1 -4
- package/_cjs/typeclass/MonadExcept.cjs.map +1 -1
- package/_mjs/collection/immutable/Conc/api.mjs +1 -4
- package/_mjs/collection/immutable/Conc/api.mjs.map +1 -1
- package/_mjs/collection/immutable/HashMap/api.mjs +4 -7
- package/_mjs/collection/immutable/HashMap/api.mjs.map +1 -1
- package/_mjs/collection/immutable/HashSet/api.mjs +4 -7
- package/_mjs/collection/immutable/HashSet/api.mjs.map +1 -1
- package/_mjs/collection/immutable/ImmutableArray/api.mjs +6 -9
- package/_mjs/collection/immutable/ImmutableArray/api.mjs.map +1 -1
- package/_mjs/collection/immutable/ImmutableArray/instances.mjs.map +1 -1
- package/_mjs/control/Pure/api.mjs +8 -20
- package/_mjs/control/Pure/api.mjs.map +1 -1
- package/_mjs/data/Cause/api.mjs +2 -8
- package/_mjs/data/Cause/api.mjs.map +1 -1
- package/_mjs/data/Datum/api.mjs +2 -8
- package/_mjs/data/Datum/api.mjs.map +1 -1
- package/_mjs/data/DatumEither/api.mjs +2 -8
- package/_mjs/data/DatumEither/api.mjs.map +1 -1
- package/_mjs/data/Either/api.mjs +6 -24
- package/_mjs/data/Either/api.mjs.map +1 -1
- package/_mjs/data/Either/destructors.mjs +3 -3
- package/_mjs/data/Either/destructors.mjs.map +1 -1
- package/_mjs/data/Either/instances.mjs +6 -25
- package/_mjs/data/Either/instances.mjs.map +1 -1
- package/_mjs/data/EitherT/api.mjs +2 -8
- package/_mjs/data/EitherT/api.mjs.map +1 -1
- package/_mjs/data/Exit/constructors.mjs +1 -4
- package/_mjs/data/Exit/constructors.mjs.map +1 -1
- package/_mjs/data/Guard/api.mjs +5 -3
- package/_mjs/data/Guard/api.mjs.map +1 -1
- package/_mjs/data/Maybe/api.mjs +1 -4
- package/_mjs/data/Maybe/api.mjs.map +1 -1
- package/_mjs/data/Maybe/instances.mjs +0 -31
- package/_mjs/data/Maybe/instances.mjs.map +1 -1
- package/_mjs/data/Showable/show.mjs.map +1 -1
- package/_mjs/data/These/instances.mjs +0 -10
- package/_mjs/data/These/instances.mjs.map +1 -1
- package/_mjs/json/EitherJson.mjs +0 -15
- package/_mjs/json/EitherJson.mjs.map +1 -1
- package/_mjs/json/MaybeJson.mjs +0 -13
- package/_mjs/json/MaybeJson.mjs.map +1 -1
- package/_mjs/json/TheseJson.mjs +0 -19
- package/_mjs/json/TheseJson.mjs.map +1 -1
- package/_mjs/optics/Optional/definition.mjs +1 -4
- package/_mjs/optics/Optional/definition.mjs.map +1 -1
- package/_mjs/optics/Prism/definition.mjs +1 -4
- package/_mjs/optics/Prism/definition.mjs.map +1 -1
- package/_mjs/typeclass/MonadExcept.mjs +1 -4
- package/_mjs/typeclass/MonadExcept.mjs.map +1 -1
- package/_src/collection/immutable/Conc/api.ts +4 -4
- package/_src/collection/immutable/HashMap/api.ts +4 -4
- package/_src/collection/immutable/HashSet/api.ts +4 -4
- package/_src/collection/immutable/ImmutableArray/api.ts +4 -4
- package/_src/collection/immutable/ImmutableArray/instances.ts +0 -2
- package/_src/control/Pure/api.ts +4 -7
- package/_src/data/Cause/api.ts +8 -8
- package/_src/data/Datum/api.ts +8 -8
- package/_src/data/DatumEither/api.ts +8 -8
- package/_src/data/Either/api.ts +18 -18
- package/_src/data/Either/destructors.ts +3 -3
- package/_src/data/Either/instances.ts +12 -31
- package/_src/data/EitherT/api.ts +8 -8
- package/_src/data/Exit/constructors.ts +1 -1
- package/_src/data/Guard/api.ts +6 -3
- package/_src/data/Maybe/api.ts +4 -4
- package/_src/data/Maybe/instances.ts +0 -39
- package/_src/data/Showable/show.ts +1 -1
- package/_src/data/These/instances.ts +0 -22
- package/_src/global.ts +0 -8
- package/_src/json/EitherJson.ts +0 -7
- package/_src/json/MaybeJson.ts +0 -7
- package/_src/json/TheseJson.ts +0 -7
- package/_src/optics/Optional/definition.ts +4 -4
- package/_src/optics/Prism/definition.ts +1 -1
- package/_src/typeclass/MonadExcept.ts +1 -1
- package/data/Either/destructors.d.ts +1 -4
- package/data/Either/instances.d.ts +0 -6
- package/data/Guard/api.d.ts +1 -2
- package/data/Maybe/instances.d.ts +0 -12
- package/data/Showable/show.d.ts +1 -1
- package/data/These/instances.d.ts +0 -6
- package/global.d.ts +0 -8
- package/json/EitherJson.d.ts +0 -6
- package/json/MaybeJson.d.ts +0 -6
- package/json/TheseJson.d.ts +0 -6
- package/package.json +2 -2
- package/_cjs/data/DecodeError/definition.cjs +0 -240
- package/_cjs/data/DecodeError/definition.cjs.map +0 -1
- package/_cjs/data/DecodeError/instances.cjs +0 -6
- package/_cjs/data/DecodeError/instances.cjs.map +0 -1
- package/_cjs/data/DecodeError.cjs +0 -28
- package/_cjs/data/DecodeError.cjs.map +0 -1
- package/_cjs/data/Decoder/api.cjs +0 -572
- package/_cjs/data/Decoder/api.cjs.map +0 -1
- package/_cjs/data/Decoder/definition.cjs +0 -30
- package/_cjs/data/Decoder/definition.cjs.map +0 -1
- package/_cjs/data/Decoder.cjs +0 -28
- package/_cjs/data/Decoder.cjs.map +0 -1
- package/_cjs/data/Encoder/api.cjs +0 -315
- package/_cjs/data/Encoder/api.cjs.map +0 -1
- package/_cjs/data/Encoder/definition.cjs +0 -22
- package/_cjs/data/Encoder/definition.cjs.map +0 -1
- package/_cjs/data/Encoder.cjs +0 -28
- package/_cjs/data/Encoder.cjs.map +0 -1
- package/_mjs/data/DecodeError/definition.mjs +0 -209
- package/_mjs/data/DecodeError/definition.mjs.map +0 -1
- package/_mjs/data/DecodeError/instances.mjs +0 -2
- package/_mjs/data/DecodeError/instances.mjs.map +0 -1
- package/_mjs/data/DecodeError.mjs +0 -5
- package/_mjs/data/DecodeError.mjs.map +0 -1
- package/_mjs/data/Decoder/api.mjs +0 -542
- package/_mjs/data/Decoder/api.mjs.map +0 -1
- package/_mjs/data/Decoder/definition.mjs +0 -22
- package/_mjs/data/Decoder/definition.mjs.map +0 -1
- package/_mjs/data/Decoder.mjs +0 -5
- package/_mjs/data/Decoder.mjs.map +0 -1
- package/_mjs/data/Encoder/api.mjs +0 -279
- package/_mjs/data/Encoder/api.mjs.map +0 -1
- package/_mjs/data/Encoder/definition.mjs +0 -15
- package/_mjs/data/Encoder/definition.mjs.map +0 -1
- package/_mjs/data/Encoder.mjs +0 -5
- package/_mjs/data/Encoder.mjs.map +0 -1
- package/_src/data/DecodeError/definition.ts +0 -267
- package/_src/data/DecodeError/instances.ts +0 -0
- package/_src/data/DecodeError.ts +0 -5
- package/_src/data/Decoder/api.ts +0 -696
- package/_src/data/Decoder/definition.ts +0 -31
- package/_src/data/Decoder.ts +0 -5
- package/_src/data/Encoder/api.ts +0 -381
- package/_src/data/Encoder/definition.ts +0 -16
- package/_src/data/Encoder.ts +0 -5
- package/data/DecodeError/definition.d.ts +0 -148
- package/data/DecodeError/instances.d.ts +0 -1
- package/data/DecodeError.d.ts +0 -2
- package/data/Decoder/api.d.ts +0 -214
- package/data/Decoder/definition.d.ts +0 -27
- package/data/Decoder.d.ts +0 -2
- package/data/Encoder/api.d.ts +0 -214
- package/data/Encoder/definition.d.ts +0 -16
- package/data/Encoder.d.ts +0 -2
package/_src/data/Either/api.ts
CHANGED
@@ -97,20 +97,20 @@ export function foldMap<A, M>(f: (a: A) => M, /** @tsplus auto */ M: P.Monoid<M>
|
|
97
97
|
* @tsplus getter fncts.Either getLeft
|
98
98
|
*/
|
99
99
|
export function getLeft<E, A>(self: Either<E, A>): Maybe<E> {
|
100
|
-
return self.match(
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
return self.match(
|
101
|
+
(e) => Just(e),
|
102
|
+
(_a) => Nothing(),
|
103
|
+
);
|
104
104
|
}
|
105
105
|
|
106
106
|
/**
|
107
107
|
* @tsplus getter fncts.Either getRight
|
108
108
|
*/
|
109
109
|
export function getRight<E, A>(self: Either<E, A>): Maybe<A> {
|
110
|
-
return self.match(
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
return self.match(
|
111
|
+
(_e) => Nothing(),
|
112
|
+
(a) => Just(a),
|
113
|
+
);
|
114
114
|
}
|
115
115
|
|
116
116
|
/**
|
@@ -118,7 +118,7 @@ export function getRight<E, A>(self: Either<E, A>): Maybe<A> {
|
|
118
118
|
*/
|
119
119
|
export function getOrElse<E, B>(orElse: (e: E) => B) {
|
120
120
|
return <A>(self: Either<E, A>): A | B => {
|
121
|
-
return self.match(
|
121
|
+
return self.match(orElse, identity);
|
122
122
|
};
|
123
123
|
}
|
124
124
|
|
@@ -172,7 +172,7 @@ export function mapLeft<E1, E2>(f: (e: E1) => E2) {
|
|
172
172
|
* @tsplus getter fncts.Either value
|
173
173
|
*/
|
174
174
|
export function merge<E, A>(self: Either<E, A>): E | A {
|
175
|
-
return self.match(
|
175
|
+
return self.match(identity, identity);
|
176
176
|
}
|
177
177
|
|
178
178
|
/**
|
@@ -201,10 +201,10 @@ export function _traverse<E, A>(self: Either<E, A>) {
|
|
201
201
|
<K, Q, W, X, I, S, R, E1, B>(
|
202
202
|
f: (a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E1, B>,
|
203
203
|
): HKT.Kind<G, GC, K, Q, W, X, I, S, R, E1, Either<E, B>> =>
|
204
|
-
self.match(
|
205
|
-
|
206
|
-
|
207
|
-
|
204
|
+
self.match(
|
205
|
+
(e) => G.pure(Left(e)),
|
206
|
+
(a) => f(a).pipe(G.map((b) => Right(b))),
|
207
|
+
);
|
208
208
|
}
|
209
209
|
|
210
210
|
export const traverse_: P.Traversable<EitherF>["traverse"] = (A) => (f) => (self) => self.traverse(A)(f);
|
@@ -288,10 +288,10 @@ export function partition<E, A>(p: Predicate<A>, /** @tsplus auto */ M: P.Monoid
|
|
288
288
|
* @tsplus getter fncts.Either toMaybe
|
289
289
|
*/
|
290
290
|
export function toMaybe<E, A>(self: Either<E, A>): Maybe<A> {
|
291
|
-
return self.match(
|
292
|
-
|
293
|
-
|
294
|
-
|
291
|
+
return self.match(
|
292
|
+
() => Nothing(),
|
293
|
+
(a) => Just(a),
|
294
|
+
);
|
295
295
|
}
|
296
296
|
|
297
297
|
/* eslint-disable simple-import-sort/exports */
|
@@ -3,14 +3,14 @@ import { EitherTag } from "./definition.js";
|
|
3
3
|
/**
|
4
4
|
* @tsplus pipeable fncts.Either match
|
5
5
|
*/
|
6
|
-
export function match<E, A, B, C>(
|
6
|
+
export function match<E, A, B, C>(onLeft: (e: E) => B, onRight: (a: A) => C) {
|
7
7
|
return (self: Either<E, A>): B | C => {
|
8
8
|
self.concrete();
|
9
9
|
switch (self._tag) {
|
10
10
|
case EitherTag.Left:
|
11
|
-
return
|
11
|
+
return onLeft(self.left);
|
12
12
|
case EitherTag.Right:
|
13
|
-
return
|
13
|
+
return onRight(self.right);
|
14
14
|
}
|
15
15
|
};
|
16
16
|
}
|
@@ -2,7 +2,6 @@ import type { EitherF } from "@fncts/base/data/Either/definition.js";
|
|
2
2
|
|
3
3
|
import { map } from "@fncts/base/data/Either/api";
|
4
4
|
import { concrete, Either, EitherTag, Right } from "@fncts/base/data/Either/definition";
|
5
|
-
import { EitherJson } from "@fncts/base/json/EitherJson";
|
6
5
|
|
7
6
|
import * as P from "../../typeclass.js";
|
8
7
|
|
@@ -20,18 +19,18 @@ export function getEq<E, A>(EE: P.Eq<E>, EA: P.Eq<A>): P.Eq<Either<E, A>> {
|
|
20
19
|
return P.Eq({
|
21
20
|
equals: (y) => (x) =>
|
22
21
|
x === y ||
|
23
|
-
x.match(
|
24
|
-
|
25
|
-
y.match(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
y.match(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
x.match(
|
23
|
+
(e1) =>
|
24
|
+
y.match(
|
25
|
+
(e2) => EE.equals(e2)(e1),
|
26
|
+
() => false,
|
27
|
+
),
|
28
|
+
(a1) =>
|
29
|
+
y.match(
|
30
|
+
() => false,
|
31
|
+
(a2) => EA.equals(a2)(a1),
|
32
|
+
),
|
33
|
+
),
|
35
34
|
});
|
36
35
|
}
|
37
36
|
|
@@ -115,21 +114,3 @@ export function deriveGuard<A extends Either<any, any>>(
|
|
115
114
|
return false;
|
116
115
|
});
|
117
116
|
}
|
118
|
-
|
119
|
-
/**
|
120
|
-
* @tsplus derive fncts.Decoder[fncts.Either]<_> 10
|
121
|
-
*/
|
122
|
-
export function deriveDecoder<A extends Either<any, any>>(
|
123
|
-
...[left, right]: [A] extends [Either<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never
|
124
|
-
): Decoder<A> {
|
125
|
-
const jsonDecoder = EitherJson.getDecoder(left, right);
|
126
|
-
return Decoder(
|
127
|
-
(u) =>
|
128
|
-
jsonDecoder
|
129
|
-
.decode(u)
|
130
|
-
.map((result) =>
|
131
|
-
result._tag === "Left" ? (Either.left(result.left) as A) : (Either.right(result.right) as A),
|
132
|
-
),
|
133
|
-
`Either<${left.label}, ${right.label}>`,
|
134
|
-
);
|
135
|
-
}
|
package/_src/data/EitherT/api.ts
CHANGED
@@ -122,10 +122,10 @@ export function flatMap<F extends HKT, FC>(F: P.Monad<F, FC>) {
|
|
122
122
|
>) =>
|
123
123
|
F.flatMap(
|
124
124
|
(either) =>
|
125
|
-
either.match(
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
either.match(
|
126
|
+
(e) => F.pure(Either.left(e)),
|
127
|
+
(a) => f(a),
|
128
|
+
) as HKT.Kind<
|
129
129
|
F,
|
130
130
|
FC,
|
131
131
|
HKT.Intro<F, "K", K, K1>,
|
@@ -225,9 +225,9 @@ export function orElse<F>(F: P.Monad<HKT.F1<F>>) {
|
|
225
225
|
that: Lazy<HKT.FK1<F, Either<E1, B>>>,
|
226
226
|
): ((self: HKT.FK1<F, Either<E, A>>) => HKT.FK1<F, Either<E | E1, A | B>>) =>
|
227
227
|
F.flatMap((either) =>
|
228
|
-
either.match(
|
229
|
-
|
230
|
-
|
231
|
-
|
228
|
+
either.match(
|
229
|
+
() => that(),
|
230
|
+
() => F.pure(either),
|
231
|
+
),
|
232
232
|
);
|
233
233
|
}
|
@@ -18,7 +18,7 @@ export function fail<E = never, A = never>(e: E, __tsplusTrace?: string): Exit<E
|
|
18
18
|
* @tsplus static fncts.ExitOps fromEither
|
19
19
|
*/
|
20
20
|
export function fromEither<E = never, A = never>(e: Either<E, A>): Exit<E, A> {
|
21
|
-
return e.match(
|
21
|
+
return e.match(fail, succeed);
|
22
22
|
}
|
23
23
|
|
24
24
|
/**
|
package/_src/data/Guard/api.ts
CHANGED
@@ -5,7 +5,7 @@ import type { OptionalKeys, RequiredKeys } from "@fncts/typelevel/Object";
|
|
5
5
|
|
6
6
|
import { Guard } from "@fncts/base/data/Guard/definition";
|
7
7
|
import { AssertionError } from "@fncts/base/util/assert";
|
8
|
-
import { isNull, isUndefined } from "@fncts/base/util/predicates";
|
8
|
+
import { isArray, isNull, isUndefined } from "@fncts/base/util/predicates";
|
9
9
|
|
10
10
|
/**
|
11
11
|
* @tsplus pipeable fncts.Guard __call
|
@@ -441,8 +441,11 @@ export function validation<A, B extends ReadonlyArray<Validation<A, any>>>(...va
|
|
441
441
|
*/
|
442
442
|
export function deriveTuple<A extends ReadonlyArray<unknown>>(
|
443
443
|
...[components]: Check<Check.IsTuple<A>> extends Check.True ? [components: { [K in keyof A]: Guard<A[K]> }] : never
|
444
|
-
):
|
445
|
-
return
|
444
|
+
): Guard<A> {
|
445
|
+
return Guard((inp): inp is A => {
|
446
|
+
if (!isArray(inp)) {
|
447
|
+
return false;
|
448
|
+
}
|
446
449
|
for (let i = 0; i < inp.length; i++) {
|
447
450
|
if (!components[i]!.is(inp[i])) {
|
448
451
|
return false;
|
package/_src/data/Maybe/api.ts
CHANGED
@@ -95,10 +95,10 @@ export function partitionMap<A, B, C>(f: (a: A) => Either<B, C>) {
|
|
95
95
|
return (self: Maybe<A>): readonly [Maybe<B>, Maybe<C>] => {
|
96
96
|
self.concrete();
|
97
97
|
if (self._tag === MaybeTag.Just) {
|
98
|
-
return f(self.value).match(
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
return f(self.value).match(
|
99
|
+
(b) => [Just(b), Nothing()],
|
100
|
+
(c) => [Nothing(), Just(c)],
|
101
|
+
);
|
102
102
|
} else {
|
103
103
|
return [Nothing(), Nothing()];
|
104
104
|
}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import type * as P from "../../typeclass.js";
|
2
2
|
import type { MaybeF } from "@fncts/base/data/Maybe/definition";
|
3
3
|
|
4
|
-
import { MaybeJson } from "@fncts/base/json/MaybeJson";
|
5
|
-
|
6
4
|
import { filter, filterMap, flatMap, foldLeft, foldRight, map, partition, partitionMap, zip, zipWith } from "./api.js";
|
7
5
|
import { just } from "./constructors.js";
|
8
6
|
|
@@ -69,40 +67,3 @@ export function deriveGuard<A extends Maybe<any>>(
|
|
69
67
|
return false;
|
70
68
|
});
|
71
69
|
}
|
72
|
-
|
73
|
-
/**
|
74
|
-
* @tsplus derive fncts.Decoder[fncts.Maybe]<_> 10
|
75
|
-
*/
|
76
|
-
export function deriveDecoder<A extends Maybe<any>>(
|
77
|
-
...[value]: [A] extends [Maybe<infer A>] ? [value: Decoder<A>] : never
|
78
|
-
): Decoder<A> {
|
79
|
-
const label = `Maybe<${value.label}>`;
|
80
|
-
return Decoder(
|
81
|
-
(input) =>
|
82
|
-
MaybeJson.getDecoder(value)
|
83
|
-
.decode(input)
|
84
|
-
.map((decoded) => (decoded._tag === "Nothing" ? (Nothing() as A) : (Just(decoded.value) as A))),
|
85
|
-
label,
|
86
|
-
);
|
87
|
-
}
|
88
|
-
|
89
|
-
/**
|
90
|
-
* @tsplus derive fncts.Encoder[fncts.Maybe]<_> 10
|
91
|
-
*/
|
92
|
-
export function deriveEncoder<A extends Maybe<any>>(
|
93
|
-
...[value]: [A] extends [Maybe<infer A>] ? [value: Encoder<A>] : never
|
94
|
-
): Encoder<A> {
|
95
|
-
return Encoder((input) => {
|
96
|
-
Maybe.concrete(input);
|
97
|
-
if (input.isJust()) {
|
98
|
-
return {
|
99
|
-
_tag: "Just",
|
100
|
-
value: value.encode(input.value),
|
101
|
-
};
|
102
|
-
} else {
|
103
|
-
return {
|
104
|
-
_tag: "Nothing",
|
105
|
-
};
|
106
|
-
}
|
107
|
-
});
|
108
|
-
}
|
@@ -129,7 +129,7 @@ export function show(value: unknown): string {
|
|
129
129
|
return _show(value).unsafeRunStateResult(getShowContext());
|
130
130
|
}
|
131
131
|
|
132
|
-
export function showWithOptions(value: unknown, options
|
132
|
+
export function showWithOptions(value: unknown, options?: Partial<ShowOptions>): string {
|
133
133
|
return _show(value).unsafeRunStateResult(getShowContext(options));
|
134
134
|
}
|
135
135
|
|
@@ -19,25 +19,3 @@ export function deriveGuard<A extends These<any, any>>(
|
|
19
19
|
return false;
|
20
20
|
});
|
21
21
|
}
|
22
|
-
|
23
|
-
/**
|
24
|
-
* @tsplus derive fncts.Decoder[fncts.These]<_> 10
|
25
|
-
*/
|
26
|
-
export function deriveDecoder<A extends These<any, any>>(
|
27
|
-
...[left, right]: [A] extends [These<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never
|
28
|
-
): Decoder<A> {
|
29
|
-
const label = `These<${left.label}, ${right.label}>`;
|
30
|
-
return Decoder(
|
31
|
-
(input) =>
|
32
|
-
TheseJson.getDecoder(left, right)
|
33
|
-
.decode(input)
|
34
|
-
.map((result) =>
|
35
|
-
result._tag === "Left"
|
36
|
-
? (These.left(result.left) as A)
|
37
|
-
: result._tag === "Right"
|
38
|
-
? (These.right(result.right) as A)
|
39
|
-
: (These.both(result.left, result.right) as A),
|
40
|
-
),
|
41
|
-
label,
|
42
|
-
);
|
43
|
-
}
|
package/_src/global.ts
CHANGED
@@ -107,10 +107,6 @@ import { Datum } from "@fncts/base/data/Datum/definition";
|
|
107
107
|
* @tsplus global
|
108
108
|
*/
|
109
109
|
import { DatumEither } from "@fncts/base/data/DatumEither/definition";
|
110
|
-
/**
|
111
|
-
* @tsplus global
|
112
|
-
*/
|
113
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
114
110
|
/**
|
115
111
|
* @tsplus global
|
116
112
|
*/
|
@@ -119,10 +115,6 @@ import { Duration } from "@fncts/base/data/Duration/definition";
|
|
119
115
|
* @tsplus global
|
120
116
|
*/
|
121
117
|
import { Either } from "@fncts/base/data/Either/definition";
|
122
|
-
/**
|
123
|
-
* @tsplus global
|
124
|
-
*/
|
125
|
-
import { Encoder } from "@fncts/base/data/Encoder/definition";
|
126
118
|
/**
|
127
119
|
* @tsplus global
|
128
120
|
*/
|
package/_src/json/EitherJson.ts
CHANGED
@@ -19,10 +19,3 @@ export type EitherJson<E, A> = LeftJson<E> | RightJson<A>;
|
|
19
19
|
export interface EitherJsonOps {}
|
20
20
|
|
21
21
|
export const EitherJson: EitherJsonOps = {};
|
22
|
-
|
23
|
-
/**
|
24
|
-
* @tsplus static fncts.EitherJsonOps getDecoder
|
25
|
-
*/
|
26
|
-
export function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<EitherJson<E, A>> {
|
27
|
-
return Derive();
|
28
|
-
}
|
package/_src/json/MaybeJson.ts
CHANGED
@@ -18,10 +18,3 @@ export type MaybeJson<A> = NothingJson | JustJson<A>;
|
|
18
18
|
export interface MaybeJsonOps {}
|
19
19
|
|
20
20
|
export const MaybeJson: MaybeJsonOps = {};
|
21
|
-
|
22
|
-
/**
|
23
|
-
* @tsplus static fncts.MaybeJsonOps getDecoder
|
24
|
-
*/
|
25
|
-
export function getDecoder<A>(value: Decoder<A>): Decoder<MaybeJson<A>> {
|
26
|
-
return Derive();
|
27
|
-
}
|
package/_src/json/TheseJson.ts
CHANGED
@@ -22,10 +22,3 @@ export type TheseJson<E, A> = LeftJson<E> | RightJson<A> | BothJson<E, A>;
|
|
22
22
|
export interface TheseJsonOps {}
|
23
23
|
|
24
24
|
export const TheseJson: TheseJsonOps = {};
|
25
|
-
|
26
|
-
/**
|
27
|
-
* @tsplus static fncts.TheseJsonOps getDecoder
|
28
|
-
*/
|
29
|
-
export function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<TheseJson<E, A>> {
|
30
|
-
return Derive();
|
31
|
-
}
|
@@ -42,10 +42,10 @@ export function makePOptional<S, T, A, B>(F: POptionalMin<S, T, A, B>): POptiona
|
|
42
42
|
modifyMaybe: (f) => (s) => getMaybe(s).map((a) => pipe(s, F.set(f(a)))),
|
43
43
|
...PTraversal<S, T, A, B>({
|
44
44
|
modifyA: (A) => (f) => (s) =>
|
45
|
-
F.getOrModify(s).match(
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
F.getOrModify(s).match(
|
46
|
+
(t) => A.pure(t),
|
47
|
+
(a) => f(a).pipe(A.map((b) => s.pipe(F.set(b)))),
|
48
|
+
),
|
49
49
|
}),
|
50
50
|
};
|
51
51
|
}
|
@@ -34,7 +34,7 @@ export function makePPrism<S, T, A, B>(F: PPrismMin<S, T, A, B>): PPrism<S, T, A
|
|
34
34
|
reverseGet: F.reverseGet,
|
35
35
|
...POptional({
|
36
36
|
getOrModify: F.getOrModify,
|
37
|
-
set: (b) => (s) => F.getOrModify(s).match(
|
37
|
+
set: (b) => (s) => F.getOrModify(s).match(identity, () => F.reverseGet(b)),
|
38
38
|
}),
|
39
39
|
};
|
40
40
|
}
|
@@ -24,5 +24,5 @@ export function absolve<F extends HKT, FC = HKT.None>(
|
|
24
24
|
export function absolve<F>(
|
25
25
|
F: MonadExcept<HKT.F<F>>,
|
26
26
|
): <E, A, E1>(fa: HKT.FK2<F, E, Either<E1, A>>) => HKT.FK2<F, HKT.Mix<HKT.F<F>, "E", [E, E1]>, A> {
|
27
|
-
return F.flatMap((r) => r.match(
|
27
|
+
return F.flatMap((r) => r.match(F.fail, F.pure));
|
28
28
|
}
|
@@ -3,7 +3,4 @@ import { Either } from "@fncts/base/data/Either/definition";
|
|
3
3
|
* @tsplus pipeable fncts.Either match
|
4
4
|
* @tsplus location "@fncts/base/data/Either/destructors"
|
5
5
|
*/
|
6
|
-
export declare function match<E, A, B, C>(
|
7
|
-
Left: (e: E) => B;
|
8
|
-
Right: (a: A) => C;
|
9
|
-
}): (self: Either<E, A>) => B | C;
|
6
|
+
export declare function match<E, A, B, C>(onLeft: (e: E) => B, onRight: (a: A) => C): (self: Either<E, A>) => B | C;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { HKT } from "@fncts/typelevel/HKT";
|
2
2
|
import { Predicate } from "@fncts/base/data/Predicate/definition";
|
3
3
|
import { Guard } from "@fncts/base/data/Guard";
|
4
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
5
4
|
import type { EitherF } from "@fncts/base/data/Either/definition.js";
|
6
5
|
import { Either } from "@fncts/base/data/Either/definition";
|
7
6
|
import * as P from "../../typeclass.js";
|
@@ -30,8 +29,3 @@ export declare function getFilerable<E>(/** @tsplus auto */ ME: P.Monoid<E>): P.
|
|
30
29
|
* @tsplus location "@fncts/base/data/Either/instances"
|
31
30
|
*/
|
32
31
|
export declare function deriveGuard<A extends Either<any, any>>(...[left, right]: [A] extends [Either<infer E, infer A>] ? [left: Guard<E>, right: Guard<A>] : never): Guard<A>;
|
33
|
-
/**
|
34
|
-
* @tsplus derive fncts.Decoder[fncts.Either]<_> 10
|
35
|
-
* @tsplus location "@fncts/base/data/Either/instances"
|
36
|
-
*/
|
37
|
-
export declare function deriveDecoder<A extends Either<any, any>>(...[left, right]: [A] extends [Either<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never): Decoder<A>;
|
package/data/Guard/api.d.ts
CHANGED
@@ -3,7 +3,6 @@ import { Predicate } from "@fncts/base/data/Predicate/definition";
|
|
3
3
|
import { ImmutableArray } from "@fncts/base/collection/immutable/ImmutableArray/definition";
|
4
4
|
import { ImmutableNonEmptyArray } from "@fncts/base/collection/immutable/ImmutableNonEmptyArray/definition";
|
5
5
|
import { Conc } from "@fncts/base/collection/immutable/Conc";
|
6
|
-
import { Encoder } from "@fncts/base/data/Encoder/definition";
|
7
6
|
import type { Brand, Validation } from "@fncts/base/data/Branded";
|
8
7
|
import type { Check } from "@fncts/typelevel";
|
9
8
|
import type { Literal } from "@fncts/typelevel/Any";
|
@@ -232,7 +231,7 @@ export declare function validation<A, B extends ReadonlyArray<Validation<A, any>
|
|
232
231
|
*/
|
233
232
|
export declare function deriveTuple<A extends ReadonlyArray<unknown>>(...[components]: Check<Check.IsTuple<A>> extends Check.True ? [components: {
|
234
233
|
[K in keyof A]: Guard<A[K]>;
|
235
|
-
}] : never):
|
234
|
+
}] : never): Guard<A>;
|
236
235
|
/**
|
237
236
|
* @tsplus static fncts.GuardOps tuple
|
238
237
|
* @tsplus location "@fncts/base/data/Guard/api"
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import { Maybe } from "@fncts/base/data/Maybe/definition";
|
2
2
|
import { Guard } from "@fncts/base/data/Guard";
|
3
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
4
|
-
import { Encoder } from "@fncts/base/data/Encoder/definition";
|
5
3
|
import type * as P from "../../typeclass.js";
|
6
4
|
import type { MaybeF } from "@fncts/base/data/Maybe/definition";
|
7
5
|
/**
|
@@ -39,13 +37,3 @@ export declare const Filterable: P.Filterable<MaybeF, import("@fncts/typelevel/H
|
|
39
37
|
* @tsplus location "@fncts/base/data/Maybe/instances"
|
40
38
|
*/
|
41
39
|
export declare function deriveGuard<A extends Maybe<any>>(...[guard]: [A] extends [Maybe<infer A>] ? [guard: Guard<A>] : never): Guard<A>;
|
42
|
-
/**
|
43
|
-
* @tsplus derive fncts.Decoder[fncts.Maybe]<_> 10
|
44
|
-
* @tsplus location "@fncts/base/data/Maybe/instances"
|
45
|
-
*/
|
46
|
-
export declare function deriveDecoder<A extends Maybe<any>>(...[value]: [A] extends [Maybe<infer A>] ? [value: Decoder<A>] : never): Decoder<A>;
|
47
|
-
/**
|
48
|
-
* @tsplus derive fncts.Encoder[fncts.Maybe]<_> 10
|
49
|
-
* @tsplus location "@fncts/base/data/Maybe/instances"
|
50
|
-
*/
|
51
|
-
export declare function deriveEncoder<A extends Maybe<any>>(...[value]: [A] extends [Maybe<infer A>] ? [value: Encoder<A>] : never): Encoder<A>;
|
package/data/Showable/show.d.ts
CHANGED
@@ -50,6 +50,6 @@ export interface ShowComputationComplex {
|
|
50
50
|
export declare function showComputationComplex(args: Omit<ShowComputationComplex, "_tag">): ShowComputationComplex;
|
51
51
|
export type ShowComputationExternal = ShowComputationPrimitive | ShowComputationComplex;
|
52
52
|
export declare function show(value: unknown): string;
|
53
|
-
export declare function showWithOptions(value: unknown, options
|
53
|
+
export declare function showWithOptions(value: unknown, options?: Partial<ShowOptions>): string;
|
54
54
|
export declare function _show(value: unknown): ShowComputation;
|
55
55
|
export declare function showProperty(value: object, key: PropertyKey, type: number, desc?: PropertyDescriptor): ShowComputation;
|
@@ -1,13 +1,7 @@
|
|
1
1
|
import { These } from "@fncts/base/data/These";
|
2
2
|
import { Guard } from "@fncts/base/data/Guard";
|
3
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
4
3
|
/**
|
5
4
|
* @tsplus derive fncts.Guard[fncts.These]<_> 10
|
6
5
|
* @tsplus location "@fncts/base/data/These/instances"
|
7
6
|
*/
|
8
7
|
export declare function deriveGuard<A extends These<any, any>>(...[left, right]: [A] extends [These<infer E, infer A>] ? [left: Guard<E>, right: Guard<A>] : never): Guard<A>;
|
9
|
-
/**
|
10
|
-
* @tsplus derive fncts.Decoder[fncts.These]<_> 10
|
11
|
-
* @tsplus location "@fncts/base/data/These/instances"
|
12
|
-
*/
|
13
|
-
export declare function deriveDecoder<A extends These<any, any>>(...[left, right]: [A] extends [These<infer E, infer A>] ? [left: Decoder<E>, right: Decoder<A>] : never): Decoder<A>;
|
package/global.d.ts
CHANGED
@@ -102,10 +102,6 @@ import { Datum } from "@fncts/base/data/Datum/definition";
|
|
102
102
|
* @tsplus global
|
103
103
|
*/
|
104
104
|
import { DatumEither } from "@fncts/base/data/DatumEither/definition";
|
105
|
-
/**
|
106
|
-
* @tsplus global
|
107
|
-
*/
|
108
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
109
105
|
/**
|
110
106
|
* @tsplus global
|
111
107
|
*/
|
@@ -114,10 +110,6 @@ import { Duration } from "@fncts/base/data/Duration/definition";
|
|
114
110
|
* @tsplus global
|
115
111
|
*/
|
116
112
|
import { Either } from "@fncts/base/data/Either/definition";
|
117
|
-
/**
|
118
|
-
* @tsplus global
|
119
|
-
*/
|
120
|
-
import { Encoder } from "@fncts/base/data/Encoder/definition";
|
121
113
|
/**
|
122
114
|
* @tsplus global
|
123
115
|
*/
|
package/json/EitherJson.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
2
1
|
export interface RightJson<A> {
|
3
2
|
readonly _tag: "Right";
|
4
3
|
readonly right: A;
|
@@ -17,8 +16,3 @@ export type EitherJson<E, A> = LeftJson<E> | RightJson<A>;
|
|
17
16
|
export interface EitherJsonOps {
|
18
17
|
}
|
19
18
|
export declare const EitherJson: EitherJsonOps;
|
20
|
-
/**
|
21
|
-
* @tsplus static fncts.EitherJsonOps getDecoder
|
22
|
-
* @tsplus location "@fncts/base/json/EitherJson"
|
23
|
-
*/
|
24
|
-
export declare function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<EitherJson<E, A>>;
|
package/json/MaybeJson.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
2
1
|
export interface NothingJson {
|
3
2
|
readonly _tag: "Nothing";
|
4
3
|
}
|
@@ -16,8 +15,3 @@ export type MaybeJson<A> = NothingJson | JustJson<A>;
|
|
16
15
|
export interface MaybeJsonOps {
|
17
16
|
}
|
18
17
|
export declare const MaybeJson: MaybeJsonOps;
|
19
|
-
/**
|
20
|
-
* @tsplus static fncts.MaybeJsonOps getDecoder
|
21
|
-
* @tsplus location "@fncts/base/json/MaybeJson"
|
22
|
-
*/
|
23
|
-
export declare function getDecoder<A>(value: Decoder<A>): Decoder<MaybeJson<A>>;
|
package/json/TheseJson.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { Decoder } from "@fncts/base/data/Decoder/definition";
|
2
1
|
export interface LeftJson<E> {
|
3
2
|
readonly _tag: "Left";
|
4
3
|
readonly left: E;
|
@@ -19,8 +18,3 @@ export type TheseJson<E, A> = LeftJson<E> | RightJson<A> | BothJson<E, A>;
|
|
19
18
|
export interface TheseJsonOps {
|
20
19
|
}
|
21
20
|
export declare const TheseJson: TheseJsonOps;
|
22
|
-
/**
|
23
|
-
* @tsplus static fncts.TheseJsonOps getDecoder
|
24
|
-
* @tsplus location "@fncts/base/json/TheseJson"
|
25
|
-
*/
|
26
|
-
export declare function getDecoder<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<TheseJson<E, A>>;
|