effect 3.3.5 → 3.4.0
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/Micro/package.json +6 -0
- package/dist/cjs/Array.js +18 -3
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/Chunk.js +13 -2
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/Effect.js +110 -8
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +31 -1
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/ManagedRuntime.js.map +1 -1
- package/dist/cjs/Micro.js +2383 -0
- package/dist/cjs/Micro.js.map +1 -0
- package/dist/cjs/Option.js +1 -2
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/Schedule.js +2 -2
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Tuple.js +16 -9
- package/dist/cjs/Tuple.js.map +1 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +4 -2
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +12 -2
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +32 -0
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Array.d.ts +14 -0
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts +1 -1
- package/dist/dts/Chunk.d.ts +11 -0
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +109 -5
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts +35 -0
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/ManagedRuntime.d.ts +15 -0
- package/dist/dts/ManagedRuntime.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +2002 -0
- package/dist/dts/Micro.d.ts.map +1 -0
- package/dist/dts/Option.d.ts +2 -0
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/Schedule.d.ts +2 -2
- package/dist/dts/Stream.d.ts +45 -6
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Tuple.d.ts +18 -0
- package/dist/dts/Tuple.d.ts.map +1 -1
- package/dist/dts/index.d.ts +7 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/esm/Array.js +14 -0
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/Chunk.js +11 -0
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/Effect.js +107 -5
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +30 -0
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/ManagedRuntime.js.map +1 -1
- package/dist/esm/Micro.js +2307 -0
- package/dist/esm/Micro.js.map +1 -0
- package/dist/esm/Option.js +1 -1
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/Schedule.js +2 -2
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/Tuple.js +15 -8
- package/dist/esm/Tuple.js.map +1 -1
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/core-effect.js +2 -0
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +10 -1
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +32 -0
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +9 -1
- package/src/Array.ts +15 -0
- package/src/Cause.ts +1 -1
- package/src/Chunk.ts +12 -0
- package/src/Effect.ts +117 -5
- package/src/Either.ts +51 -0
- package/src/ManagedRuntime.ts +16 -0
- package/src/Micro.ts +3826 -0
- package/src/Option.ts +12 -1
- package/src/Schedule.ts +2 -2
- package/src/Stream.ts +60 -8
- package/src/Tuple.ts +18 -8
- package/src/index.ts +8 -0
- package/src/internal/core-effect.ts +33 -0
- package/src/internal/core.ts +18 -1
- package/src/internal/fiberRuntime.ts +32 -0
- package/src/internal/stream.ts +8 -4
- package/src/internal/version.ts +1 -1
|
@@ -0,0 +1,2002 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A lightweight alternative to the `Effect` data type, with a subset of the functionality.
|
|
3
|
+
*
|
|
4
|
+
* @since 3.4.0
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
import type { Channel, ChannelTypeId } from "./Channel.js";
|
|
8
|
+
import * as Context from "./Context.js";
|
|
9
|
+
import type { Effect, EffectTypeId } from "./Effect.js";
|
|
10
|
+
import * as Either from "./Either.js";
|
|
11
|
+
import { type LazyArg } from "./Function.js";
|
|
12
|
+
import type { Inspectable } from "./Inspectable.js";
|
|
13
|
+
import * as Option from "./Option.js";
|
|
14
|
+
import { type Pipeable } from "./Pipeable.js";
|
|
15
|
+
import { type Predicate, type Refinement } from "./Predicate.js";
|
|
16
|
+
import type { ReadonlyRecord } from "./Record.js";
|
|
17
|
+
import type { Sink, SinkTypeId } from "./Sink.js";
|
|
18
|
+
import type { Stream, StreamTypeId } from "./Stream.js";
|
|
19
|
+
import type { Concurrency, Covariant, Equals, NoInfer, NotFunction, Simplify } from "./Types.js";
|
|
20
|
+
import { YieldWrap } from "./Utils.js";
|
|
21
|
+
/**
|
|
22
|
+
* @since 3.4.0
|
|
23
|
+
* @experimental
|
|
24
|
+
* @category type ids
|
|
25
|
+
*/
|
|
26
|
+
export declare const TypeId: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* @since 3.4.0
|
|
29
|
+
* @experimental
|
|
30
|
+
* @category type ids
|
|
31
|
+
*/
|
|
32
|
+
export type TypeId = typeof TypeId;
|
|
33
|
+
/**
|
|
34
|
+
* @since 3.4.0
|
|
35
|
+
* @experimental
|
|
36
|
+
* @category symbols
|
|
37
|
+
*/
|
|
38
|
+
export declare const runSymbol: unique symbol;
|
|
39
|
+
/**
|
|
40
|
+
* @since 3.4.0
|
|
41
|
+
* @experimental
|
|
42
|
+
* @category symbols
|
|
43
|
+
*/
|
|
44
|
+
export type runSymbol = typeof runSymbol;
|
|
45
|
+
/**
|
|
46
|
+
* A lightweight alternative to the `Effect` data type, with a subset of the functionality.
|
|
47
|
+
*
|
|
48
|
+
* @since 3.4.0
|
|
49
|
+
* @experimental
|
|
50
|
+
* @category models
|
|
51
|
+
*/
|
|
52
|
+
export interface Micro<out A, out E = never, out R = never> extends Effect<A, E, R> {
|
|
53
|
+
readonly [TypeId]: Micro.Variance<A, E, R>;
|
|
54
|
+
readonly [runSymbol]: (env: Env<any>, onResult: (result: Result<A, E>) => void) => void;
|
|
55
|
+
[Symbol.iterator](): MicroIterator<Micro<A, E, R>>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @since 3.4.0
|
|
59
|
+
* @experimental
|
|
60
|
+
*/
|
|
61
|
+
export declare namespace Micro {
|
|
62
|
+
/**
|
|
63
|
+
* @since 3.4.0
|
|
64
|
+
* @experimental
|
|
65
|
+
*/
|
|
66
|
+
interface Variance<A, E, R> {
|
|
67
|
+
_A: Covariant<A>;
|
|
68
|
+
_E: Covariant<E>;
|
|
69
|
+
_R: Covariant<R>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @since 3.4.0
|
|
73
|
+
* @experimental
|
|
74
|
+
*/
|
|
75
|
+
type Success<T> = T extends Micro<infer _A, infer _E, infer _R> ? _A : never;
|
|
76
|
+
/**
|
|
77
|
+
* @since 3.4.0
|
|
78
|
+
* @experimental
|
|
79
|
+
*/
|
|
80
|
+
type Error<T> = T extends Micro<infer _A, infer _E, infer _R> ? _E : never;
|
|
81
|
+
/**
|
|
82
|
+
* @since 3.4.0
|
|
83
|
+
* @experimental
|
|
84
|
+
*/
|
|
85
|
+
type Context<T> = T extends Micro<infer _A, infer _E, infer _R> ? _R : never;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @since 3.4.0
|
|
89
|
+
* @experimental
|
|
90
|
+
* @category guards
|
|
91
|
+
*/
|
|
92
|
+
export declare const isMicro: (u: unknown) => u is Micro<any, any, any>;
|
|
93
|
+
/**
|
|
94
|
+
* @since 3.4.0
|
|
95
|
+
* @experimental
|
|
96
|
+
* @category models
|
|
97
|
+
*/
|
|
98
|
+
export interface MicroIterator<T extends Micro<any, any, any>> {
|
|
99
|
+
next(...args: ReadonlyArray<any>): IteratorResult<YieldWrap<T>, Micro.Success<T>>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @since 3.4.0
|
|
103
|
+
* @experimental
|
|
104
|
+
* @category failure
|
|
105
|
+
*/
|
|
106
|
+
export declare const FailureTypeId: unique symbol;
|
|
107
|
+
/**
|
|
108
|
+
* @since 3.4.0
|
|
109
|
+
* @experimental
|
|
110
|
+
* @category failure
|
|
111
|
+
*/
|
|
112
|
+
export type FailureTypeId = typeof FailureTypeId;
|
|
113
|
+
/**
|
|
114
|
+
* A Micro Failure is a data type that represents the different ways a Micro can fail.
|
|
115
|
+
*
|
|
116
|
+
* @since 3.4.0
|
|
117
|
+
* @experimental
|
|
118
|
+
* @category failure
|
|
119
|
+
*/
|
|
120
|
+
export type Failure<E> = Failure.Unexpected | Failure.Expected<E> | Failure.Aborted;
|
|
121
|
+
/**
|
|
122
|
+
* @since 3.4.0
|
|
123
|
+
* @experimental
|
|
124
|
+
* @category failure
|
|
125
|
+
*/
|
|
126
|
+
export declare namespace Failure {
|
|
127
|
+
/**
|
|
128
|
+
* @since 3.4.0
|
|
129
|
+
* @experimental
|
|
130
|
+
*/
|
|
131
|
+
interface Proto<Tag extends string, E> extends Pipeable, globalThis.Error {
|
|
132
|
+
readonly [FailureTypeId]: {
|
|
133
|
+
_E: Covariant<E>;
|
|
134
|
+
};
|
|
135
|
+
readonly _tag: Tag;
|
|
136
|
+
readonly traces: ReadonlyArray<string>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @since 3.4.0
|
|
140
|
+
* @experimental
|
|
141
|
+
* @category failure
|
|
142
|
+
*/
|
|
143
|
+
interface Unexpected extends Proto<"Unexpected", never> {
|
|
144
|
+
readonly defect: unknown;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @since 3.4.0
|
|
148
|
+
* @experimental
|
|
149
|
+
* @category failure
|
|
150
|
+
*/
|
|
151
|
+
interface Expected<E> extends Proto<"Expected", E> {
|
|
152
|
+
readonly error: E;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @since 3.4.0
|
|
156
|
+
* @experimental
|
|
157
|
+
* @category failure
|
|
158
|
+
*/
|
|
159
|
+
interface Aborted extends Proto<"Aborted", never> {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @since 3.4.0
|
|
164
|
+
* @experimental
|
|
165
|
+
* @category failure
|
|
166
|
+
*/
|
|
167
|
+
export declare const FailureExpected: <E>(error: E, traces?: ReadonlyArray<string>) => Failure<E>;
|
|
168
|
+
/**
|
|
169
|
+
* @since 3.4.0
|
|
170
|
+
* @experimental
|
|
171
|
+
* @category failure
|
|
172
|
+
*/
|
|
173
|
+
export declare const FailureUnexpected: (defect: unknown, traces?: ReadonlyArray<string>) => Failure<never>;
|
|
174
|
+
/**
|
|
175
|
+
* @since 3.4.0
|
|
176
|
+
* @experimental
|
|
177
|
+
* @category failure
|
|
178
|
+
*/
|
|
179
|
+
export declare const FailureAborted: (traces?: ReadonlyArray<string>) => Failure<never>;
|
|
180
|
+
/**
|
|
181
|
+
* @since 3.4.0
|
|
182
|
+
* @experimental
|
|
183
|
+
* @category failure
|
|
184
|
+
*/
|
|
185
|
+
export declare const failureIsExpected: <E>(self: Failure<E>) => self is Failure.Expected<E>;
|
|
186
|
+
/**
|
|
187
|
+
* @since 3.4.0
|
|
188
|
+
* @experimental
|
|
189
|
+
* @category failure
|
|
190
|
+
*/
|
|
191
|
+
export declare const failureIsUnexpected: <E>(self: Failure<E>) => self is Failure.Unexpected;
|
|
192
|
+
/**
|
|
193
|
+
* @since 3.4.0
|
|
194
|
+
* @experimental
|
|
195
|
+
* @category failure
|
|
196
|
+
*/
|
|
197
|
+
export declare const failureIsAborted: <E>(self: Failure<E>) => self is Failure.Aborted;
|
|
198
|
+
/**
|
|
199
|
+
* @since 3.4.0
|
|
200
|
+
* @experimental
|
|
201
|
+
* @category failure
|
|
202
|
+
*/
|
|
203
|
+
export declare const failureSquash: <E>(self: Failure<E>) => unknown;
|
|
204
|
+
/**
|
|
205
|
+
* @since 3.4.0
|
|
206
|
+
* @experimental
|
|
207
|
+
* @category failure
|
|
208
|
+
*/
|
|
209
|
+
export declare const failureWithTrace: {
|
|
210
|
+
(trace: string): <E>(self: Failure<E>) => Failure<E>;
|
|
211
|
+
<E>(self: Failure<E>, trace: string): Failure<E>;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* The Micro Result type is a data type that represents the result of a Micro
|
|
215
|
+
* computation.
|
|
216
|
+
*
|
|
217
|
+
* It uses the `Either` data type to represent the success and failure cases.
|
|
218
|
+
*
|
|
219
|
+
* @since 3.4.0
|
|
220
|
+
* @experimental
|
|
221
|
+
* @category result
|
|
222
|
+
*/
|
|
223
|
+
export type Result<A, E = never> = Either.Either<A, Failure<E>>;
|
|
224
|
+
/**
|
|
225
|
+
* @since 3.4.0
|
|
226
|
+
* @experimental
|
|
227
|
+
* @category result
|
|
228
|
+
*/
|
|
229
|
+
export declare const ResultAborted: Result<never>;
|
|
230
|
+
/**
|
|
231
|
+
* @since 3.4.0
|
|
232
|
+
* @experimental
|
|
233
|
+
* @category result
|
|
234
|
+
*/
|
|
235
|
+
export declare const ResultSuccess: <A>(a: A) => Result<A, never>;
|
|
236
|
+
/**
|
|
237
|
+
* @since 3.4.0
|
|
238
|
+
* @experimental
|
|
239
|
+
* @category result
|
|
240
|
+
*/
|
|
241
|
+
export declare const ResultFail: <E>(e: E) => Result<never, E>;
|
|
242
|
+
/**
|
|
243
|
+
* @since 3.4.0
|
|
244
|
+
* @experimental
|
|
245
|
+
* @category result
|
|
246
|
+
*/
|
|
247
|
+
export declare const ResultFailUnexpected: (defect: unknown) => Result<never>;
|
|
248
|
+
/**
|
|
249
|
+
* @since 3.4.0
|
|
250
|
+
* @experimental
|
|
251
|
+
* @category result
|
|
252
|
+
*/
|
|
253
|
+
export declare const ResultFailWith: <E>(failure: Failure<E>) => Result<never, E>;
|
|
254
|
+
/**
|
|
255
|
+
* @since 3.4.0
|
|
256
|
+
* @experimental
|
|
257
|
+
* @category result
|
|
258
|
+
*/
|
|
259
|
+
export declare const resultIsSuccess: <A, E>(self: Result<A, E>) => self is Either.Right<Failure<E>, A>;
|
|
260
|
+
/**
|
|
261
|
+
* @since 3.4.0
|
|
262
|
+
* @experimental
|
|
263
|
+
* @category result
|
|
264
|
+
*/
|
|
265
|
+
export declare const resultIsFailure: <A, E>(self: Result<A, E>) => self is Either.Left<Failure<E>, A>;
|
|
266
|
+
/**
|
|
267
|
+
* @since 3.4.0
|
|
268
|
+
* @experimental
|
|
269
|
+
* @category result
|
|
270
|
+
*/
|
|
271
|
+
export declare const resultIsAborted: <A, E>(self: Result<A, E>) => self is Either.Left<Failure.Aborted, A>;
|
|
272
|
+
/**
|
|
273
|
+
* @since 3.4.0
|
|
274
|
+
* @experimental
|
|
275
|
+
* @category result
|
|
276
|
+
*/
|
|
277
|
+
export declare const resultIsFailureExpected: <A, E>(self: Result<A, E>) => self is Either.Left<Failure.Expected<E>, A>;
|
|
278
|
+
/**
|
|
279
|
+
* @since 3.4.0
|
|
280
|
+
* @experimental
|
|
281
|
+
* @category result
|
|
282
|
+
*/
|
|
283
|
+
export declare const resultIsFailureUnexpected: <A, E>(self: Result<A, E>) => self is Either.Left<Failure.Unexpected, A>;
|
|
284
|
+
/**
|
|
285
|
+
* @since 3.4.0
|
|
286
|
+
* @experimental
|
|
287
|
+
* @category result
|
|
288
|
+
*/
|
|
289
|
+
export declare const resultVoid: Result<void>;
|
|
290
|
+
/**
|
|
291
|
+
* @since 3.4.0
|
|
292
|
+
* @experimental
|
|
293
|
+
* @category environment
|
|
294
|
+
*/
|
|
295
|
+
export declare const EnvTypeId: unique symbol;
|
|
296
|
+
/**
|
|
297
|
+
* @since 3.4.0
|
|
298
|
+
* @experimental
|
|
299
|
+
* @category environment
|
|
300
|
+
*/
|
|
301
|
+
export type EnvTypeId = typeof EnvTypeId;
|
|
302
|
+
/**
|
|
303
|
+
* @since 3.4.0
|
|
304
|
+
* @experimental
|
|
305
|
+
* @category environment
|
|
306
|
+
*/
|
|
307
|
+
export interface Env<R> extends Pipeable {
|
|
308
|
+
readonly [EnvTypeId]: {
|
|
309
|
+
_R: Covariant<R>;
|
|
310
|
+
};
|
|
311
|
+
readonly refs: ReadonlyRecord<string, unknown>;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @since 3.4.0
|
|
315
|
+
* @experimental
|
|
316
|
+
* @category environment
|
|
317
|
+
*/
|
|
318
|
+
export declare const EnvRefTypeId: unique symbol;
|
|
319
|
+
/**
|
|
320
|
+
* @since 3.4.0
|
|
321
|
+
* @experimental
|
|
322
|
+
* @category environment
|
|
323
|
+
*/
|
|
324
|
+
export type EnvRefTypeId = typeof EnvRefTypeId;
|
|
325
|
+
/**
|
|
326
|
+
* @since 3.4.0
|
|
327
|
+
* @experimental
|
|
328
|
+
* @category environment
|
|
329
|
+
*/
|
|
330
|
+
export interface EnvRef<A> {
|
|
331
|
+
readonly [EnvRefTypeId]: EnvRefTypeId;
|
|
332
|
+
readonly key: string;
|
|
333
|
+
readonly initial: A;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* @since 3.4.0
|
|
337
|
+
* @experimental
|
|
338
|
+
* @category environment
|
|
339
|
+
*/
|
|
340
|
+
export declare const envMake: <R = never>(refs: Record<string, unknown>) => Env<R>;
|
|
341
|
+
/**
|
|
342
|
+
* @since 3.4.0
|
|
343
|
+
* @experimental
|
|
344
|
+
* @category environment
|
|
345
|
+
*/
|
|
346
|
+
export declare const envUnsafeMakeEmpty: () => Env<never>;
|
|
347
|
+
/**
|
|
348
|
+
* @since 3.4.0
|
|
349
|
+
* @experimental
|
|
350
|
+
* @category environment
|
|
351
|
+
*/
|
|
352
|
+
export declare const envGet: {
|
|
353
|
+
<A>(ref: EnvRef<A>): <R>(self: Env<R>) => A;
|
|
354
|
+
<A, R>(self: Env<R>, ref: EnvRef<A>): A;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* @since 3.4.0
|
|
358
|
+
* @experimental
|
|
359
|
+
* @category environment
|
|
360
|
+
*/
|
|
361
|
+
export declare const envSet: {
|
|
362
|
+
<A>(ref: EnvRef<A>, value: A): <R>(self: Env<R>) => Env<R>;
|
|
363
|
+
<A, R>(self: Env<R>, ref: EnvRef<A>, value: A): Env<R>;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* @since 3.4.0
|
|
367
|
+
* @experimental
|
|
368
|
+
* @category environment
|
|
369
|
+
*/
|
|
370
|
+
export declare const envMutate: {
|
|
371
|
+
(f: (map: Record<string, unknown>) => void): <R>(self: Env<R>) => Env<R>;
|
|
372
|
+
<R>(self: Env<R>, f: (map: Record<string, unknown>) => void): Env<R>;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Access the given `Context.Tag` from the environment.
|
|
376
|
+
*
|
|
377
|
+
* @since 3.4.0
|
|
378
|
+
* @experimental
|
|
379
|
+
* @category environment
|
|
380
|
+
*/
|
|
381
|
+
export declare const service: <I, S>(tag: Context.Tag<I, S>) => Micro<S, never, I>;
|
|
382
|
+
/**
|
|
383
|
+
* Access the given `Context.Tag` from the environment, without tracking the
|
|
384
|
+
* dependency at the type level.
|
|
385
|
+
*
|
|
386
|
+
* It will return an `Option` of the service, depending on whether it is
|
|
387
|
+
* available in the environment or not.
|
|
388
|
+
*
|
|
389
|
+
* @since 3.4.0
|
|
390
|
+
* @experimental
|
|
391
|
+
* @category environment
|
|
392
|
+
*/
|
|
393
|
+
export declare const serviceOption: <I, S>(tag: Context.Tag<I, S>) => Micro<Option.Option<S>>;
|
|
394
|
+
/**
|
|
395
|
+
* Retrieve the current value of the given `EnvRef`.
|
|
396
|
+
*
|
|
397
|
+
* @since 3.4.0
|
|
398
|
+
* @experimental
|
|
399
|
+
* @category environment
|
|
400
|
+
*/
|
|
401
|
+
export declare const getEnvRef: <A>(envRef: EnvRef<A>) => Micro<A>;
|
|
402
|
+
/**
|
|
403
|
+
* Set the value of the given `EnvRef` for the duration of the effect.
|
|
404
|
+
*
|
|
405
|
+
* @since 3.4.0
|
|
406
|
+
* @experimental
|
|
407
|
+
* @category environment
|
|
408
|
+
*/
|
|
409
|
+
export declare const locally: {
|
|
410
|
+
<A>(fiberRef: EnvRef<A>, value: A): <XA, E, R>(self: Micro<XA, E, R>) => Micro<XA, E, R>;
|
|
411
|
+
<XA, E, R, A>(self: Micro<XA, E, R>, fiberRef: EnvRef<A>, value: A): Micro<XA, E, R>;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* Access the current `Context` from the environment.
|
|
415
|
+
*
|
|
416
|
+
* @since 3.4.0
|
|
417
|
+
* @experimental
|
|
418
|
+
* @category environment
|
|
419
|
+
*/
|
|
420
|
+
export declare const context: <R>() => Micro<Context.Context<R>>;
|
|
421
|
+
/**
|
|
422
|
+
* Merge the given `Context` with the current context.
|
|
423
|
+
*
|
|
424
|
+
* @since 3.4.0
|
|
425
|
+
* @experimental
|
|
426
|
+
* @category environment
|
|
427
|
+
*/
|
|
428
|
+
export declare const provideContext: {
|
|
429
|
+
<XR>(context: Context.Context<XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, XR>>;
|
|
430
|
+
<A, E, R, XR>(self: Micro<A, E, R>, context: Context.Context<XR>): Micro<A, E, Exclude<R, XR>>;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Add the provided service to the current context.
|
|
434
|
+
*
|
|
435
|
+
* @since 3.4.0
|
|
436
|
+
* @experimental
|
|
437
|
+
* @category environment
|
|
438
|
+
*/
|
|
439
|
+
export declare const provideService: {
|
|
440
|
+
<I, S>(tag: Context.Tag<I, S>, service: S): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, I>>;
|
|
441
|
+
<A, E, R, I, S>(self: Micro<A, E, R>, tag: Context.Tag<I, S>, service: S): Micro<A, E, Exclude<R, I>>;
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* Create a service using the provided `Micro` effect, and add it to the
|
|
445
|
+
* current context.
|
|
446
|
+
*
|
|
447
|
+
* @since 3.4.0
|
|
448
|
+
* @experimental
|
|
449
|
+
* @category environment
|
|
450
|
+
*/
|
|
451
|
+
export declare const provideServiceMicro: {
|
|
452
|
+
<I, S, E2, R2>(tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | E2, Exclude<R, I> | R2>;
|
|
453
|
+
<A, E, R, I, S, E2, R2>(self: Micro<A, E, R>, tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): Micro<A, E | E2, Exclude<R, I> | R2>;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* @since 3.4.0
|
|
457
|
+
* @experimental
|
|
458
|
+
* @category environment refs
|
|
459
|
+
*/
|
|
460
|
+
export declare const envRefMake: <A>(key: string, initial: LazyArg<A>) => EnvRef<A>;
|
|
461
|
+
/**
|
|
462
|
+
* @since 3.4.0
|
|
463
|
+
* @experimental
|
|
464
|
+
* @category environment refs
|
|
465
|
+
*/
|
|
466
|
+
export declare const currentAbortController: EnvRef<AbortController>;
|
|
467
|
+
/**
|
|
468
|
+
* @since 3.4.0
|
|
469
|
+
* @experimental
|
|
470
|
+
* @category environment refs
|
|
471
|
+
*/
|
|
472
|
+
export declare const currentAbortSignal: EnvRef<AbortSignal>;
|
|
473
|
+
/**
|
|
474
|
+
* @since 3.4.0
|
|
475
|
+
* @experimental
|
|
476
|
+
* @category environment refs
|
|
477
|
+
*/
|
|
478
|
+
export declare const currentContext: EnvRef<Context.Context<never>>;
|
|
479
|
+
/**
|
|
480
|
+
* @since 3.4.0
|
|
481
|
+
* @experimental
|
|
482
|
+
* @category environment refs
|
|
483
|
+
*/
|
|
484
|
+
export declare const currentConcurrency: EnvRef<"unbounded" | number>;
|
|
485
|
+
/**
|
|
486
|
+
* @since 3.4.0
|
|
487
|
+
* @experimental
|
|
488
|
+
* @category environment refs
|
|
489
|
+
*/
|
|
490
|
+
export declare const currentMaxDepthBeforeYield: EnvRef<number>;
|
|
491
|
+
/**
|
|
492
|
+
* If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
|
|
493
|
+
* api to control the concurrency of that `Micro` when it is run.
|
|
494
|
+
*
|
|
495
|
+
* @since 3.4.0
|
|
496
|
+
* @experimental
|
|
497
|
+
* @category environment refs
|
|
498
|
+
* @example
|
|
499
|
+
* import * as Micro from "effect/Micro"
|
|
500
|
+
*
|
|
501
|
+
* Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
|
|
502
|
+
* concurrency: "inherit"
|
|
503
|
+
* }).pipe(
|
|
504
|
+
* Micro.withConcurrency(2) // use a concurrency of 2
|
|
505
|
+
* )
|
|
506
|
+
*/
|
|
507
|
+
export declare const withConcurrency: {
|
|
508
|
+
(concurrency: "unbounded" | number): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
509
|
+
<A, E, R>(self: Micro<A, E, R>, concurrency: "unbounded" | number): Micro<A, E, R>;
|
|
510
|
+
};
|
|
511
|
+
/**
|
|
512
|
+
* A low-level constructor for creating a `Micro` effect. It takes a function
|
|
513
|
+
* that receives an environment and a callback which should be called with the
|
|
514
|
+
* result of the effect.
|
|
515
|
+
*
|
|
516
|
+
* @since 3.4.0
|
|
517
|
+
* @experimental
|
|
518
|
+
* @category constructors
|
|
519
|
+
*/
|
|
520
|
+
export declare const make: <A, E, R>(run: (env: Env<R>, onResult: (result: Result<A, E>) => void) => void) => Micro<A, E, R>;
|
|
521
|
+
/**
|
|
522
|
+
* Converts a `Result` into a `Micro` effect.
|
|
523
|
+
*
|
|
524
|
+
* @since 3.4.0
|
|
525
|
+
* @experimental
|
|
526
|
+
* @category constructors
|
|
527
|
+
*/
|
|
528
|
+
export declare const fromResult: <A, E>(self: Result<A, E>) => Micro<A, E>;
|
|
529
|
+
/**
|
|
530
|
+
* Converts a lazy `Result` into a `Micro` effect.
|
|
531
|
+
*
|
|
532
|
+
* @since 3.4.0
|
|
533
|
+
* @experimental
|
|
534
|
+
* @category constructors
|
|
535
|
+
*/
|
|
536
|
+
export declare const fromResultSync: <A, E>(self: LazyArg<Result<A, E>>) => Micro<A, E>;
|
|
537
|
+
/**
|
|
538
|
+
* Creates a `Micro` effect that will succeed with the specified constant value.
|
|
539
|
+
*
|
|
540
|
+
* @since 3.4.0
|
|
541
|
+
* @experimental
|
|
542
|
+
* @category constructors
|
|
543
|
+
*/
|
|
544
|
+
export declare const succeed: <A>(a: A) => Micro<A>;
|
|
545
|
+
/**
|
|
546
|
+
* Creates a `Micro` effect that will succeed with `Option.Some` of the value.
|
|
547
|
+
*
|
|
548
|
+
* @since 3.4.0
|
|
549
|
+
* @experimental
|
|
550
|
+
* @category constructors
|
|
551
|
+
*/
|
|
552
|
+
export declare const succeedSome: <A>(a: A) => Micro<Option.Option<A>>;
|
|
553
|
+
/**
|
|
554
|
+
* Creates a `Micro` effect that will succeed with `Option.None`.
|
|
555
|
+
*
|
|
556
|
+
* @since 3.4.0
|
|
557
|
+
* @experimental
|
|
558
|
+
* @category constructors
|
|
559
|
+
*/
|
|
560
|
+
export declare const succeedNone: Micro<Option.Option<never>>;
|
|
561
|
+
/**
|
|
562
|
+
* Creates a `Micro` effect that will fail with the specified error.
|
|
563
|
+
*
|
|
564
|
+
* This will result in a `FailureExpected`, where the error is tracked at the
|
|
565
|
+
* type level.
|
|
566
|
+
*
|
|
567
|
+
* @since 3.4.0
|
|
568
|
+
* @experimental
|
|
569
|
+
* @category constructors
|
|
570
|
+
*/
|
|
571
|
+
export declare const fail: <E>(e: E) => Micro<never, E>;
|
|
572
|
+
/**
|
|
573
|
+
* Creates a `Micro` effect that will fail with the lazily evaluated error.
|
|
574
|
+
*
|
|
575
|
+
* This will result in a `FailureExpected`, where the error is tracked at the
|
|
576
|
+
* type level.
|
|
577
|
+
*
|
|
578
|
+
* @since 3.4.0
|
|
579
|
+
* @experimental
|
|
580
|
+
* @category constructors
|
|
581
|
+
*/
|
|
582
|
+
export declare const failSync: <E>(e: LazyArg<E>) => Micro<never, E>;
|
|
583
|
+
/**
|
|
584
|
+
* Creates a `Micro` effect that will die with the specified error.
|
|
585
|
+
*
|
|
586
|
+
* This will result in a `FailureUnexpected`, where the error is not tracked at
|
|
587
|
+
* the type level.
|
|
588
|
+
*
|
|
589
|
+
* @since 3.4.0
|
|
590
|
+
* @experimental
|
|
591
|
+
* @category constructors
|
|
592
|
+
*/
|
|
593
|
+
export declare const die: (defect: unknown) => Micro<never>;
|
|
594
|
+
/**
|
|
595
|
+
* Creates a `Micro` effect that will fail with the specified `Failure`.
|
|
596
|
+
*
|
|
597
|
+
* @since 3.4.0
|
|
598
|
+
* @experimental
|
|
599
|
+
* @category constructors
|
|
600
|
+
*/
|
|
601
|
+
export declare const failWith: <E>(failure: Failure<E>) => Micro<never, E>;
|
|
602
|
+
/**
|
|
603
|
+
* Creates a `Micro` effect that will fail with the lazily evaluated `Failure`.
|
|
604
|
+
*
|
|
605
|
+
* @since 3.4.0
|
|
606
|
+
* @experimental
|
|
607
|
+
* @category constructors
|
|
608
|
+
*/
|
|
609
|
+
export declare const failWithSync: <E>(failure: LazyArg<Failure<E>>) => Micro<never, E>;
|
|
610
|
+
/**
|
|
611
|
+
* Creates a `Micro` effect that will succeed with the lazily evaluated value.
|
|
612
|
+
*
|
|
613
|
+
* If the evaluation of the value throws an error, the effect will fail with
|
|
614
|
+
* `FailureUnexpected`.
|
|
615
|
+
*
|
|
616
|
+
* @since 3.4.0
|
|
617
|
+
* @experimental
|
|
618
|
+
* @category constructors
|
|
619
|
+
*/
|
|
620
|
+
export declare const sync: <A>(evaluate: LazyArg<A>) => Micro<A>;
|
|
621
|
+
/**
|
|
622
|
+
* Converts an `Option` into a `Micro` effect, that will fail with a
|
|
623
|
+
* `Option.None` if the option is `None`. Otherwise, it will succeed with the
|
|
624
|
+
* value of the option.
|
|
625
|
+
*
|
|
626
|
+
* @since 3.4.0
|
|
627
|
+
* @experimental
|
|
628
|
+
* @category constructors
|
|
629
|
+
*/
|
|
630
|
+
export declare const fromOption: <A>(option: Option.Option<A>) => Micro<A, Option.None<never>>;
|
|
631
|
+
/**
|
|
632
|
+
* Converts an `Either` into a `Micro` effect, that will fail with the left side
|
|
633
|
+
* of the either if it is a `Left`. Otherwise, it will succeed with the right
|
|
634
|
+
* side of the either.
|
|
635
|
+
*
|
|
636
|
+
* @since 3.4.0
|
|
637
|
+
* @experimental
|
|
638
|
+
* @category constructors
|
|
639
|
+
*/
|
|
640
|
+
export declare const fromEither: <R, L>(either: Either.Either<R, L>) => Micro<R, L>;
|
|
641
|
+
/**
|
|
642
|
+
* Lazily creates a `Micro` effect from the given side-effect.
|
|
643
|
+
*
|
|
644
|
+
* @since 3.4.0
|
|
645
|
+
* @experimental
|
|
646
|
+
* @category constructors
|
|
647
|
+
*/
|
|
648
|
+
export declare const suspend: <A, E, R>(evaluate: LazyArg<Micro<A, E, R>>) => Micro<A, E, R>;
|
|
649
|
+
declare const void_: Micro<void>;
|
|
650
|
+
export {
|
|
651
|
+
/**
|
|
652
|
+
* A `Micro` effect that will succeed with `void` (`undefined`).
|
|
653
|
+
*
|
|
654
|
+
* @since 3.4.0
|
|
655
|
+
* @experimental
|
|
656
|
+
* @category constructors
|
|
657
|
+
*/
|
|
658
|
+
void_ as void };
|
|
659
|
+
/**
|
|
660
|
+
* Create a `Micro` effect from an asynchronous computation.
|
|
661
|
+
*
|
|
662
|
+
* You can return a cleanup effect that will be run when the effect is aborted.
|
|
663
|
+
* It is also passed an `AbortSignal` that is triggered when the effect is
|
|
664
|
+
* aborted.
|
|
665
|
+
*
|
|
666
|
+
* @since 3.4.0
|
|
667
|
+
* @experimental
|
|
668
|
+
* @category constructors
|
|
669
|
+
*/
|
|
670
|
+
export declare const async: <A, E = never, R = never>(register: (resume: (effect: Micro<A, E, R>) => void, signal: AbortSignal) => void | Micro<void, never, R>) => Micro<A, E, R>;
|
|
671
|
+
declare const try_: <A, E>(options: {
|
|
672
|
+
try: LazyArg<A>;
|
|
673
|
+
catch: (error: unknown) => E;
|
|
674
|
+
}) => Micro<A, E>;
|
|
675
|
+
export {
|
|
676
|
+
/**
|
|
677
|
+
* The `Micro` equivalent of a try / catch block, which allows you to map
|
|
678
|
+
* thrown errors to a specific error type.
|
|
679
|
+
*
|
|
680
|
+
* @since 3.4.0
|
|
681
|
+
* @experimental
|
|
682
|
+
* @category constructors
|
|
683
|
+
* @example
|
|
684
|
+
* import { Micro } from "effect"
|
|
685
|
+
*
|
|
686
|
+
* Micro.try({
|
|
687
|
+
* try: () => throw new Error("boom"),
|
|
688
|
+
* catch: (cause) => new Error("caught", { cause })
|
|
689
|
+
* })
|
|
690
|
+
*/
|
|
691
|
+
try_ as try };
|
|
692
|
+
/**
|
|
693
|
+
* Wrap a `Promise` into a `Micro` effect. Any errors will result in a
|
|
694
|
+
* `FailureUnexpected`.
|
|
695
|
+
*
|
|
696
|
+
* @since 3.4.0
|
|
697
|
+
* @experimental
|
|
698
|
+
* @category constructors
|
|
699
|
+
*/
|
|
700
|
+
export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Micro<A>;
|
|
701
|
+
/**
|
|
702
|
+
* Wrap a `Promise` into a `Micro` effect. Any errors will be caught and
|
|
703
|
+
* converted into a specific error type.
|
|
704
|
+
*
|
|
705
|
+
* @since 3.4.0
|
|
706
|
+
* @experimental
|
|
707
|
+
* @category constructors
|
|
708
|
+
* @example
|
|
709
|
+
* import { Micro } from "effect"
|
|
710
|
+
*
|
|
711
|
+
* Micro.tryPromise({
|
|
712
|
+
* try: () => Promise.resolve("success"),
|
|
713
|
+
* catch: (cause) => new Error("caught", { cause })
|
|
714
|
+
* })
|
|
715
|
+
*/
|
|
716
|
+
export declare const tryPromise: <A, E>(options: {
|
|
717
|
+
readonly try: (signal: AbortSignal) => PromiseLike<A>;
|
|
718
|
+
readonly catch: (error: unknown) => E;
|
|
719
|
+
}) => Micro<A, E>;
|
|
720
|
+
/**
|
|
721
|
+
* Pause the execution of the current `Micro` effect, and resume it on the next
|
|
722
|
+
* iteration of the event loop.
|
|
723
|
+
*
|
|
724
|
+
* @since 3.4.0
|
|
725
|
+
* @experimental
|
|
726
|
+
* @category constructors
|
|
727
|
+
*/
|
|
728
|
+
export declare const yieldNow: Micro<void>;
|
|
729
|
+
/**
|
|
730
|
+
* Flush any yielded effects that are waiting to be executed.
|
|
731
|
+
*
|
|
732
|
+
* @since 3.4.0
|
|
733
|
+
* @experimental
|
|
734
|
+
* @category constructors
|
|
735
|
+
*/
|
|
736
|
+
export declare const yieldFlush: Micro<void>;
|
|
737
|
+
/**
|
|
738
|
+
* A `Micro` that will never succeed or fail. It wraps `setInterval` to prevent
|
|
739
|
+
* the Javascript runtime from exiting.
|
|
740
|
+
*
|
|
741
|
+
* @since 3.4.0
|
|
742
|
+
* @experimental
|
|
743
|
+
* @category constructors
|
|
744
|
+
*/
|
|
745
|
+
export declare const never: Micro<never>;
|
|
746
|
+
/**
|
|
747
|
+
* @since 3.4.0
|
|
748
|
+
* @experimental
|
|
749
|
+
* @category constructors
|
|
750
|
+
*/
|
|
751
|
+
export declare const gen: <Eff extends YieldWrap<Micro<any, any, any>>, AEff>(f: () => Generator<Eff, AEff, never>) => Micro<AEff, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Micro<infer _A, infer E, infer _R>>] ? E : never, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Micro<infer _A_1, infer _E, infer R>>] ? R : never>;
|
|
752
|
+
/**
|
|
753
|
+
* Flattens any nested `Micro` effects, merging the error and requirement types.
|
|
754
|
+
*
|
|
755
|
+
* @since 3.4.0
|
|
756
|
+
* @experimental
|
|
757
|
+
* @category mapping & sequencing
|
|
758
|
+
*/
|
|
759
|
+
export declare const flatten: <A, E, R, E2, R2>(self: Micro<Micro<A, E, R>, E2, R2>) => Micro<A, E | E2, R | R2>;
|
|
760
|
+
/**
|
|
761
|
+
* Transforms the success value of the `Micro` effect with the specified
|
|
762
|
+
* function.
|
|
763
|
+
*
|
|
764
|
+
* @since 3.4.0
|
|
765
|
+
* @experimental
|
|
766
|
+
* @category mapping & sequencing
|
|
767
|
+
*/
|
|
768
|
+
export declare const map: {
|
|
769
|
+
<A, B>(f: (a: A) => B): <E, R>(self: Micro<A, E, R>) => Micro<B, E, R>;
|
|
770
|
+
<A, E, R, B>(self: Micro<A, E, R>, f: (a: A) => B): Micro<B, E, R>;
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* Create a `Micro` effect that will replace the success value of the given
|
|
774
|
+
* effect.
|
|
775
|
+
*
|
|
776
|
+
* @since 3.4.0
|
|
777
|
+
* @experimental
|
|
778
|
+
* @category mapping & sequencing
|
|
779
|
+
*/
|
|
780
|
+
export declare const as: {
|
|
781
|
+
<A, B>(value: B): <E, R>(self: Micro<A, E, R>) => Micro<B, E, R>;
|
|
782
|
+
<A, E, R, B>(self: Micro<A, E, R>, value: B): Micro<B, E, R>;
|
|
783
|
+
};
|
|
784
|
+
/**
|
|
785
|
+
* Wrap the success value of this `Micro` effect in an `Option.Some`.
|
|
786
|
+
*
|
|
787
|
+
* @since 3.4.0
|
|
788
|
+
* @experimental
|
|
789
|
+
* @category mapping & sequencing
|
|
790
|
+
*/
|
|
791
|
+
export declare const asSome: <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Option<A>, E, R>;
|
|
792
|
+
/**
|
|
793
|
+
* Map the success value of this `Micro` effect to another `Micro` effect, then
|
|
794
|
+
* flatten the result.
|
|
795
|
+
*
|
|
796
|
+
* @since 3.4.0
|
|
797
|
+
* @experimental
|
|
798
|
+
* @category mapping & sequencing
|
|
799
|
+
*/
|
|
800
|
+
export declare const flatMap: {
|
|
801
|
+
<A, B, E2, R2>(f: (a: A) => Micro<B, E2, R2>): <E, R>(self: Micro<A, E, R>) => Micro<B, E | E2, R | R2>;
|
|
802
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (a: A) => Micro<B, E2, R2>): Micro<B, E | E2, R | R2>;
|
|
803
|
+
};
|
|
804
|
+
/**
|
|
805
|
+
* Swap the error and success types of the `Micro` effect.
|
|
806
|
+
*
|
|
807
|
+
* @since 3.4.0
|
|
808
|
+
* @experimental
|
|
809
|
+
* @category mapping & sequencing
|
|
810
|
+
*/
|
|
811
|
+
export declare const flip: <A, E, R>(self: Micro<A, E, R>) => Micro<E, A, R>;
|
|
812
|
+
/**
|
|
813
|
+
* A more flexible version of `flatMap`, that combines `map` and `flatMap` into
|
|
814
|
+
* a single api.
|
|
815
|
+
*
|
|
816
|
+
* It also allows you to pass in a `Micro` effect directly, which will be
|
|
817
|
+
* executed after the current effect.
|
|
818
|
+
*
|
|
819
|
+
* @since 3.4.0
|
|
820
|
+
* @experimental
|
|
821
|
+
* @category mapping & sequencing
|
|
822
|
+
*/
|
|
823
|
+
export declare const andThen: {
|
|
824
|
+
<A, X>(f: (a: A) => X): <E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
|
|
825
|
+
<X>(f: NotFunction<X>): <A, E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
|
|
826
|
+
<A, E, R, X>(self: Micro<A, E, R>, f: (a: A) => X): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
|
|
827
|
+
<A, E, R, X>(self: Micro<A, E, R>, f: NotFunction<X>): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
|
|
828
|
+
};
|
|
829
|
+
/**
|
|
830
|
+
* Execute a side effect from the success value of the `Micro` effect.
|
|
831
|
+
*
|
|
832
|
+
* It is similar to the `andThen` api, but the success value is ignored.
|
|
833
|
+
*
|
|
834
|
+
* @since 3.4.0
|
|
835
|
+
* @experimental
|
|
836
|
+
* @category mapping & sequencing
|
|
837
|
+
*/
|
|
838
|
+
export declare const tap: {
|
|
839
|
+
<A, X>(f: (a: NoInfer<A>) => X): <E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
|
|
840
|
+
<X>(f: NotFunction<X>): <A, E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
|
|
841
|
+
<A, E, R, X>(self: Micro<A, E, R>, f: (a: NoInfer<A>) => X): [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
|
|
842
|
+
<A, E, R, X>(self: Micro<A, E, R>, f: NotFunction<X>): [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
|
|
843
|
+
};
|
|
844
|
+
/**
|
|
845
|
+
* Replace the success value of the `Micro` effect with `void`.
|
|
846
|
+
*
|
|
847
|
+
* @since 3.4.0
|
|
848
|
+
* @experimental
|
|
849
|
+
* @category mapping & sequencing
|
|
850
|
+
*/
|
|
851
|
+
export declare const asVoid: <A, E, R>(self: Micro<A, E, R>) => Micro<void, E, R>;
|
|
852
|
+
/**
|
|
853
|
+
* Access the `Result` of the given `Micro` effect.
|
|
854
|
+
*
|
|
855
|
+
* @since 3.4.0
|
|
856
|
+
* @experimental
|
|
857
|
+
* @category mapping & sequencing
|
|
858
|
+
*/
|
|
859
|
+
export declare const asResult: <A, E, R>(self: Micro<A, E, R>) => Micro<Result<A, E>, never, R>;
|
|
860
|
+
/**
|
|
861
|
+
* Replace the error type of the given `Micro` with the full `Failure` object.
|
|
862
|
+
*
|
|
863
|
+
* @since 3.4.0
|
|
864
|
+
* @experimental
|
|
865
|
+
* @category mapping & sequencing
|
|
866
|
+
*/
|
|
867
|
+
export declare const sandbox: <A, E, R>(self: Micro<A, E, R>) => Micro<A, Failure<E>, R>;
|
|
868
|
+
/**
|
|
869
|
+
* Returns an effect that races all the specified effects,
|
|
870
|
+
* yielding the value of the first effect to succeed with a value. Losers of
|
|
871
|
+
* the race will be interrupted immediately
|
|
872
|
+
*
|
|
873
|
+
* @since 3.4.0
|
|
874
|
+
* @experimental
|
|
875
|
+
* @category sequencing
|
|
876
|
+
*/
|
|
877
|
+
export declare const raceAll: <Eff extends Micro<any, any, any>>(all: Iterable<Eff>) => Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>>;
|
|
878
|
+
/**
|
|
879
|
+
* Returns an effect that races all the specified effects,
|
|
880
|
+
* yielding the value of the first effect to succeed or fail. Losers of
|
|
881
|
+
* the race will be interrupted immediately
|
|
882
|
+
*
|
|
883
|
+
* @since 3.4.0
|
|
884
|
+
* @experimental
|
|
885
|
+
* @category sequencing
|
|
886
|
+
*/
|
|
887
|
+
export declare const raceAllFirst: <Eff extends Micro<any, any, any>>(all: Iterable<Eff>) => Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>>;
|
|
888
|
+
/**
|
|
889
|
+
* Returns an effect that races two effects, yielding the value of the first
|
|
890
|
+
* effect to succeed. Losers of the race will be interrupted immediately
|
|
891
|
+
*
|
|
892
|
+
* @since 3.4.0
|
|
893
|
+
* @experimental
|
|
894
|
+
* @category sequencing
|
|
895
|
+
*/
|
|
896
|
+
export declare const race: {
|
|
897
|
+
<A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
|
|
898
|
+
<A, E, R, A2, E2, R2>(self: Micro<A, E, R>, that: Micro<A2, E2, R2>): Micro<A | A2, E | E2, R | R2>;
|
|
899
|
+
};
|
|
900
|
+
/**
|
|
901
|
+
* Returns an effect that races two effects, yielding the value of the first
|
|
902
|
+
* effect to succeed *or* fail. Losers of the race will be interrupted immediately
|
|
903
|
+
*
|
|
904
|
+
* @since 3.4.0
|
|
905
|
+
* @experimental
|
|
906
|
+
* @category sequencing
|
|
907
|
+
*/
|
|
908
|
+
export declare const raceFirst: {
|
|
909
|
+
<A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
|
|
910
|
+
<A, E, R, A2, E2, R2>(self: Micro<A, E, R>, that: Micro<A2, E2, R2>): Micro<A | A2, E | E2, R | R2>;
|
|
911
|
+
};
|
|
912
|
+
/**
|
|
913
|
+
* Combine two `Micro` effects into a single effect that produces a tuple of
|
|
914
|
+
* their results.
|
|
915
|
+
*
|
|
916
|
+
* @since 3.4.0
|
|
917
|
+
* @experimental
|
|
918
|
+
* @category zipping
|
|
919
|
+
*/
|
|
920
|
+
export declare const zip: {
|
|
921
|
+
<A2, E2, R2>(that: Micro<A2, E2, R2>, options?: {
|
|
922
|
+
readonly concurrent?: boolean | undefined;
|
|
923
|
+
} | undefined): <A, E, R>(self: Micro<A, E, R>) => Micro<[A, A2], E2 | E, R2 | R>;
|
|
924
|
+
<A, E, R, A2, E2, R2>(self: Micro<A, E, R>, that: Micro<A2, E2, R2>, options?: {
|
|
925
|
+
readonly concurrent?: boolean | undefined;
|
|
926
|
+
} | undefined): Micro<[A, A2], E | E2, R | R2>;
|
|
927
|
+
};
|
|
928
|
+
/**
|
|
929
|
+
* Filter the specified effect with the provided function, failing with specified
|
|
930
|
+
* `Failure` if the predicate fails.
|
|
931
|
+
*
|
|
932
|
+
* In addition to the filtering capabilities discussed earlier, you have the option to further
|
|
933
|
+
* refine and narrow down the type of the success channel by providing a
|
|
934
|
+
*
|
|
935
|
+
* @since 3.4.0
|
|
936
|
+
* @experimental
|
|
937
|
+
* @category filtering & conditionals
|
|
938
|
+
*/
|
|
939
|
+
export declare const filterOrFailWith: {
|
|
940
|
+
<A, B extends A, E2>(refinement: Refinement<A, B>, orFailWith: (a: NoInfer<A>) => Failure<E2>): <E, R>(self: Micro<A, E, R>) => Micro<B, E2 | E, R>;
|
|
941
|
+
<A, E2>(predicate: Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => Failure<E2>): <E, R>(self: Micro<A, E, R>) => Micro<A, E2 | E, R>;
|
|
942
|
+
<A, E, R, B extends A, E2>(self: Micro<A, E, R>, refinement: Refinement<A, B>, orFailWith: (a: A) => Failure<E2>): Micro<B, E | E2, R>;
|
|
943
|
+
<A, E, R, E2>(self: Micro<A, E, R>, predicate: Predicate<A>, orFailWith: (a: A) => Failure<E2>): Micro<A, E | E2, R>;
|
|
944
|
+
};
|
|
945
|
+
/**
|
|
946
|
+
* Filter the specified effect with the provided function, failing with specified
|
|
947
|
+
* error if the predicate fails.
|
|
948
|
+
*
|
|
949
|
+
* In addition to the filtering capabilities discussed earlier, you have the option to further
|
|
950
|
+
* refine and narrow down the type of the success channel by providing a
|
|
951
|
+
*
|
|
952
|
+
* @since 3.4.0
|
|
953
|
+
* @experimental
|
|
954
|
+
* @category filtering & conditionals
|
|
955
|
+
*/
|
|
956
|
+
export declare const filterOrFail: {
|
|
957
|
+
<A, B extends A, E2>(refinement: Refinement<A, B>, orFailWith: (a: NoInfer<A>) => E2): <E, R>(self: Micro<A, E, R>) => Micro<B, E2 | E, R>;
|
|
958
|
+
<A, E2>(predicate: Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): <E, R>(self: Micro<A, E, R>) => Micro<A, E2 | E, R>;
|
|
959
|
+
<A, E, R, B extends A, E2>(self: Micro<A, E, R>, refinement: Refinement<A, B>, orFailWith: (a: A) => E2): Micro<B, E | E2, R>;
|
|
960
|
+
<A, E, R, E2>(self: Micro<A, E, R>, predicate: Predicate<A>, orFailWith: (a: A) => E2): Micro<A, E | E2, R>;
|
|
961
|
+
};
|
|
962
|
+
/**
|
|
963
|
+
* The moral equivalent of `if (p) exp`.
|
|
964
|
+
*
|
|
965
|
+
* @since 3.4.0
|
|
966
|
+
* @experimental
|
|
967
|
+
* @category filtering & conditionals
|
|
968
|
+
*/
|
|
969
|
+
export declare const when: {
|
|
970
|
+
<E2 = never, R2 = never>(condition: LazyArg<boolean> | Micro<boolean, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Option<A>, E | E2, R | R2>;
|
|
971
|
+
<A, E, R, E2 = never, R2 = never>(self: Micro<A, E, R>, condition: LazyArg<boolean> | Micro<boolean, E2, R2>): Micro<Option.Option<A>, E | E2, R | R2>;
|
|
972
|
+
};
|
|
973
|
+
/**
|
|
974
|
+
* Repeat the given `Micro` using the provided options.
|
|
975
|
+
*
|
|
976
|
+
* The `while` predicate will be checked after each iteration, and can use the
|
|
977
|
+
* fall `Result` of the effect to determine if the repetition should continue.
|
|
978
|
+
*
|
|
979
|
+
* @since 3.4.0
|
|
980
|
+
* @experimental
|
|
981
|
+
* @category repetition
|
|
982
|
+
*/
|
|
983
|
+
export declare const repeatResult: {
|
|
984
|
+
<A, E>(options: {
|
|
985
|
+
while: Predicate<Result<A, E>>;
|
|
986
|
+
times?: number | undefined;
|
|
987
|
+
delay?: DelayFn | undefined;
|
|
988
|
+
}): <R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
989
|
+
<A, E, R>(self: Micro<A, E, R>, options: {
|
|
990
|
+
while: Predicate<Result<A, E>>;
|
|
991
|
+
times?: number | undefined;
|
|
992
|
+
delay?: DelayFn | undefined;
|
|
993
|
+
}): Micro<A, E, R>;
|
|
994
|
+
};
|
|
995
|
+
/**
|
|
996
|
+
* Repeat the given `Micro` effect using the provided options. Only successful
|
|
997
|
+
* results will be repeated.
|
|
998
|
+
*
|
|
999
|
+
* @since 3.4.0
|
|
1000
|
+
* @experimental
|
|
1001
|
+
* @category repetition
|
|
1002
|
+
*/
|
|
1003
|
+
export declare const repeat: {
|
|
1004
|
+
<A, E>(options?: {
|
|
1005
|
+
while?: Predicate<A> | undefined;
|
|
1006
|
+
times?: number | undefined;
|
|
1007
|
+
delay?: DelayFn | undefined;
|
|
1008
|
+
} | undefined): <R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1009
|
+
<A, E, R>(self: Micro<A, E, R>, options?: {
|
|
1010
|
+
while?: Predicate<A> | undefined;
|
|
1011
|
+
times?: number | undefined;
|
|
1012
|
+
delay?: DelayFn | undefined;
|
|
1013
|
+
} | undefined): Micro<A, E, R>;
|
|
1014
|
+
};
|
|
1015
|
+
/**
|
|
1016
|
+
* Repeat the given `Micro` effect forever, only stopping if the effect fails.
|
|
1017
|
+
*
|
|
1018
|
+
* @since 3.4.0
|
|
1019
|
+
* @experimental
|
|
1020
|
+
* @category repetition
|
|
1021
|
+
*/
|
|
1022
|
+
export declare const forever: <A, E, R>(self: Micro<A, E, R>) => Micro<never, E, R>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Represents a function that can be used to calculate the delay between
|
|
1025
|
+
* repeats.
|
|
1026
|
+
*
|
|
1027
|
+
* The function takes the current attempt number and the elapsed time since
|
|
1028
|
+
* the first attempt, and returns the delay for the next attempt. If the
|
|
1029
|
+
* function returns `None`, the repetition will stop.
|
|
1030
|
+
*
|
|
1031
|
+
* @since 3.4.0
|
|
1032
|
+
* @experimental
|
|
1033
|
+
* @category delay fn
|
|
1034
|
+
*/
|
|
1035
|
+
export type DelayFn = (attempt: number, elapsed: number) => Option.Option<number>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Create a `DelayFn` that will generate a duration with an exponential backoff.
|
|
1038
|
+
*
|
|
1039
|
+
* @since 3.4.0
|
|
1040
|
+
* @experimental
|
|
1041
|
+
* @category delay fn
|
|
1042
|
+
*/
|
|
1043
|
+
export declare const delayExponential: (baseMillis: number, factor?: number) => DelayFn;
|
|
1044
|
+
/**
|
|
1045
|
+
* Create a `DelayFn` that will generate a duration with fixed intervals.
|
|
1046
|
+
*
|
|
1047
|
+
* @since 3.4.0
|
|
1048
|
+
* @experimental
|
|
1049
|
+
* @category delay fn
|
|
1050
|
+
*/
|
|
1051
|
+
export declare const delaySpaced: (millis: number) => DelayFn;
|
|
1052
|
+
/**
|
|
1053
|
+
* Transform a `DelayFn` to one that will have a duration that will never exceed
|
|
1054
|
+
* the specified maximum.
|
|
1055
|
+
*
|
|
1056
|
+
* @since 3.4.0
|
|
1057
|
+
* @experimental
|
|
1058
|
+
* @category delay fn
|
|
1059
|
+
*/
|
|
1060
|
+
export declare const delayWithMax: {
|
|
1061
|
+
(max: number): (self: DelayFn) => DelayFn;
|
|
1062
|
+
(self: DelayFn, max: number): DelayFn;
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* Transform a `DelayFn` to one that will stop repeating after the specified
|
|
1066
|
+
* amount of time.
|
|
1067
|
+
*
|
|
1068
|
+
* @since 3.4.0
|
|
1069
|
+
* @experimental
|
|
1070
|
+
* @category delay fn
|
|
1071
|
+
*/
|
|
1072
|
+
export declare const delayWithMaxElapsed: {
|
|
1073
|
+
(max: number): (self: DelayFn) => DelayFn;
|
|
1074
|
+
(self: DelayFn, max: number): DelayFn;
|
|
1075
|
+
};
|
|
1076
|
+
/**
|
|
1077
|
+
* Transform a `DelayFn` to one that will stop repeating after the specified
|
|
1078
|
+
* number of attempts.
|
|
1079
|
+
*
|
|
1080
|
+
* @since 3.4.0
|
|
1081
|
+
* @experimental
|
|
1082
|
+
* @category delay fn
|
|
1083
|
+
*/
|
|
1084
|
+
export declare const delayWithRecurs: {
|
|
1085
|
+
(n: number): (self: DelayFn) => DelayFn;
|
|
1086
|
+
(self: DelayFn, n: number): DelayFn;
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* Catch the full `Failure` object of the given `Micro` effect, allowing you to
|
|
1090
|
+
* recover from any kind of failure.
|
|
1091
|
+
*
|
|
1092
|
+
* @since 3.4.0
|
|
1093
|
+
* @experimental
|
|
1094
|
+
* @category error handling
|
|
1095
|
+
*/
|
|
1096
|
+
export declare const catchFailure: {
|
|
1097
|
+
<E, B, E2, R2>(f: (failure: NoInfer<Failure<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1098
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (failure: NoInfer<Failure<E>>) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1099
|
+
};
|
|
1100
|
+
/**
|
|
1101
|
+
* Selectively catch a `Failure` object of the given `Micro` effect,
|
|
1102
|
+
* using the provided predicate to determine if the failure should be caught.
|
|
1103
|
+
*
|
|
1104
|
+
* @since 3.4.0
|
|
1105
|
+
* @experimental
|
|
1106
|
+
* @category error handling
|
|
1107
|
+
*/
|
|
1108
|
+
export declare const catchFailureIf: {
|
|
1109
|
+
<E, B, E2, R2, EB extends Failure<E>>(refinement: Refinement<Failure<E>, EB>, f: (failure: EB) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1110
|
+
<E, B, E2, R2>(predicate: Predicate<Failure<NoInfer<E>>>, f: (failure: NoInfer<Failure<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1111
|
+
<A, E, R, B, E2, R2, EB extends Failure<E>>(self: Micro<A, E, R>, refinement: Refinement<Failure<E>, EB>, f: (failure: EB) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1112
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, predicate: Predicate<Failure<NoInfer<E>>>, f: (failure: NoInfer<Failure<E>>) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1113
|
+
};
|
|
1114
|
+
/**
|
|
1115
|
+
* Catch the error of the given `Micro` effect, allowing you to recover from it.
|
|
1116
|
+
*
|
|
1117
|
+
* It only catches expected (`FailureExpected`) errors.
|
|
1118
|
+
*
|
|
1119
|
+
* @since 3.4.0
|
|
1120
|
+
* @experimental
|
|
1121
|
+
* @category error handling
|
|
1122
|
+
*/
|
|
1123
|
+
export declare const catchExpected: {
|
|
1124
|
+
<E, B, E2, R2>(f: (e: NoInfer<E>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1125
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (e: NoInfer<E>) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1126
|
+
};
|
|
1127
|
+
/**
|
|
1128
|
+
* Catch any unexpected errors of the given `Micro` effect, allowing you to recover from them.
|
|
1129
|
+
*
|
|
1130
|
+
* @since 3.4.0
|
|
1131
|
+
* @experimental
|
|
1132
|
+
* @category error handling
|
|
1133
|
+
*/
|
|
1134
|
+
export declare const catchUnexpected: {
|
|
1135
|
+
<E, B, E2, R2>(f: (defect: unknown) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E | E2, R | R2>;
|
|
1136
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (defect: unknown) => Micro<B, E2, R2>): Micro<A | B, E | E2, R | R2>;
|
|
1137
|
+
};
|
|
1138
|
+
/**
|
|
1139
|
+
* Perform a side effect using the full `Failure` object of the given `Micro`.
|
|
1140
|
+
*
|
|
1141
|
+
* @since 3.4.0
|
|
1142
|
+
* @experimental
|
|
1143
|
+
* @category error handling
|
|
1144
|
+
*/
|
|
1145
|
+
export declare const tapFailure: {
|
|
1146
|
+
<E, B, E2, R2>(f: (a: NoInfer<Failure<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1147
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (a: NoInfer<Failure<E>>) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* Perform a side effect using if a `Failure` object matches the specified
|
|
1151
|
+
* predicate.
|
|
1152
|
+
*
|
|
1153
|
+
* @since 3.4.0
|
|
1154
|
+
* @experimental
|
|
1155
|
+
* @category error handling
|
|
1156
|
+
*/
|
|
1157
|
+
export declare const tapFailureIf: {
|
|
1158
|
+
<E, B, E2, R2, EB extends Failure<E>>(refinement: Refinement<Failure<E>, EB>, f: (a: EB) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1159
|
+
<E, B, E2, R2>(predicate: (failure: NoInfer<Failure<E>>) => boolean, f: (a: NoInfer<Failure<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1160
|
+
<A, E, R, B, E2, R2, EB extends Failure<E>>(self: Micro<A, E, R>, refinement: Refinement<Failure<E>, EB>, f: (a: EB) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1161
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, predicate: (failure: NoInfer<Failure<E>>) => boolean, f: (a: NoInfer<Failure<E>>) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1162
|
+
};
|
|
1163
|
+
/**
|
|
1164
|
+
* Perform a side effect from expected errors of the given `Micro`.
|
|
1165
|
+
*
|
|
1166
|
+
* @since 3.4.0
|
|
1167
|
+
* @experimental
|
|
1168
|
+
* @category error handling
|
|
1169
|
+
*/
|
|
1170
|
+
export declare const tapExpected: {
|
|
1171
|
+
<E, B, E2, R2>(f: (a: NoInfer<E>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1172
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (a: NoInfer<E>) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1173
|
+
};
|
|
1174
|
+
/**
|
|
1175
|
+
* Perform a side effect from unexpected errors of the given `Micro`.
|
|
1176
|
+
*
|
|
1177
|
+
* @since 3.4.0
|
|
1178
|
+
* @experimental
|
|
1179
|
+
* @category error handling
|
|
1180
|
+
*/
|
|
1181
|
+
export declare const tapUnexpected: {
|
|
1182
|
+
<E, B, E2, R2>(f: (defect: unknown) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1183
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (defect: unknown) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1184
|
+
};
|
|
1185
|
+
/**
|
|
1186
|
+
* Catch any expected errors that match the specified predicate.
|
|
1187
|
+
*
|
|
1188
|
+
* @since 3.4.0
|
|
1189
|
+
* @experimental
|
|
1190
|
+
* @category error handling
|
|
1191
|
+
*/
|
|
1192
|
+
export declare const catchIf: {
|
|
1193
|
+
<E, EB extends E, B, E2, R2>(pred: Refinement<E, EB>, f: (a: NoInfer<EB>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1194
|
+
<E, B, E2, R2>(pred: Predicate<NoInfer<E>>, f: (a: NoInfer<E>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1195
|
+
<A, E, R, EB extends E, B, E2, R2>(self: Micro<A, E, R>, pred: Refinement<E, EB>, f: (a: NoInfer<EB>) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1196
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, pred: Predicate<NoInfer<E>>, f: (a: NoInfer<E>) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1197
|
+
};
|
|
1198
|
+
/**
|
|
1199
|
+
* Recovers from the specified tagged error.
|
|
1200
|
+
*
|
|
1201
|
+
* @since 3.4.0
|
|
1202
|
+
* @experimental
|
|
1203
|
+
* @category error handling
|
|
1204
|
+
*/
|
|
1205
|
+
export declare const catchTag: {
|
|
1206
|
+
<K extends E extends {
|
|
1207
|
+
_tag: string;
|
|
1208
|
+
} ? E["_tag"] : never, E, A1, E1, R1>(k: K, f: (e: Extract<E, {
|
|
1209
|
+
_tag: K;
|
|
1210
|
+
}>) => Micro<A1, E1, R1>): <A, R>(self: Micro<A, E, R>) => Micro<A1 | A, E1 | Exclude<E, {
|
|
1211
|
+
_tag: K;
|
|
1212
|
+
}>, R1 | R>;
|
|
1213
|
+
<A, E, R, K extends E extends {
|
|
1214
|
+
_tag: string;
|
|
1215
|
+
} ? E["_tag"] : never, R1, E1, A1>(self: Micro<A, E, R>, k: K, f: (e: Extract<E, {
|
|
1216
|
+
_tag: K;
|
|
1217
|
+
}>) => Micro<A1, E1, R1>): Micro<A | A1, E1 | Exclude<E, {
|
|
1218
|
+
_tag: K;
|
|
1219
|
+
}>, R | R1>;
|
|
1220
|
+
};
|
|
1221
|
+
/**
|
|
1222
|
+
* Transform the full `Failure` object of the given `Micro` effect.
|
|
1223
|
+
*
|
|
1224
|
+
* @since 3.4.0
|
|
1225
|
+
* @experimental
|
|
1226
|
+
* @category error handling
|
|
1227
|
+
*/
|
|
1228
|
+
export declare const mapFailure: {
|
|
1229
|
+
<E, E2>(f: (a: Failure<E>) => Failure<E2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E2, R>;
|
|
1230
|
+
<A, E, R, E2>(self: Micro<A, E, R>, f: (a: Failure<E>) => Failure<E2>): Micro<A, E2, R>;
|
|
1231
|
+
};
|
|
1232
|
+
/**
|
|
1233
|
+
* Transform any expected errors of the given `Micro` effect.
|
|
1234
|
+
*
|
|
1235
|
+
* @since 3.4.0
|
|
1236
|
+
* @experimental
|
|
1237
|
+
* @category error handling
|
|
1238
|
+
*/
|
|
1239
|
+
export declare const mapError: {
|
|
1240
|
+
<E, E2>(f: (a: E) => E2): <A, R>(self: Micro<A, E, R>) => Micro<A, E2, R>;
|
|
1241
|
+
<A, E, R, E2>(self: Micro<A, E, R>, f: (a: E) => E2): Micro<A, E2, R>;
|
|
1242
|
+
};
|
|
1243
|
+
/**
|
|
1244
|
+
* Elevate any expected errors of the given `Micro` effect to unexpected errors,
|
|
1245
|
+
* resulting in an error type of `never`.
|
|
1246
|
+
*
|
|
1247
|
+
* @since 3.4.0
|
|
1248
|
+
* @experimental
|
|
1249
|
+
* @category error handling
|
|
1250
|
+
*/
|
|
1251
|
+
export declare const orDie: <A, E, R>(self: Micro<A, E, R>) => Micro<A, never, R>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Recover from all errors by succeeding with the given value.
|
|
1254
|
+
*
|
|
1255
|
+
* @since 3.4.0
|
|
1256
|
+
* @experimental
|
|
1257
|
+
* @category error handling
|
|
1258
|
+
*/
|
|
1259
|
+
export declare const orElseSucceed: {
|
|
1260
|
+
<B>(f: LazyArg<B>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | B, never, R>;
|
|
1261
|
+
<A, E, R, B>(self: Micro<A, E, R>, f: LazyArg<B>): Micro<A | B, never, R>;
|
|
1262
|
+
};
|
|
1263
|
+
/**
|
|
1264
|
+
* Ignore any expected errors of the given `Micro` effect, returning `void`.
|
|
1265
|
+
*
|
|
1266
|
+
* @since 3.4.0
|
|
1267
|
+
* @experimental
|
|
1268
|
+
* @category error handling
|
|
1269
|
+
*/
|
|
1270
|
+
export declare const ignore: <A, E, R>(self: Micro<A, E, R>) => Micro<void, never, R>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Ignore any expected errors of the given `Micro` effect, returning `void`.
|
|
1273
|
+
*
|
|
1274
|
+
* @since 3.4.0
|
|
1275
|
+
* @experimental
|
|
1276
|
+
* @category error handling
|
|
1277
|
+
*/
|
|
1278
|
+
export declare const ignoreLogged: <A, E, R>(self: Micro<A, E, R>) => Micro<void, never, R>;
|
|
1279
|
+
/**
|
|
1280
|
+
* Replace the success value of the given `Micro` effect with an `Option`,
|
|
1281
|
+
* wrapping the success value in `Some` and returning `None` if the effect fails
|
|
1282
|
+
* with an expected error.
|
|
1283
|
+
*
|
|
1284
|
+
* @since 3.4.0
|
|
1285
|
+
* @experimental
|
|
1286
|
+
* @category error handling
|
|
1287
|
+
*/
|
|
1288
|
+
export declare const option: <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Option<A>, never, R>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Replace the success value of the given `Micro` effect with an `Either`,
|
|
1291
|
+
* wrapping the success value in `Right` and wrapping any expected errors with
|
|
1292
|
+
* a `Left`.
|
|
1293
|
+
*
|
|
1294
|
+
* @since 3.4.0
|
|
1295
|
+
* @experimental
|
|
1296
|
+
* @category error handling
|
|
1297
|
+
*/
|
|
1298
|
+
export declare const either: <A, E, R>(self: Micro<A, E, R>) => Micro<Either.Either<A, E>, never, R>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Retry the given `Micro` effect using the provided options.
|
|
1301
|
+
*
|
|
1302
|
+
* @since 3.4.0
|
|
1303
|
+
* @experimental
|
|
1304
|
+
* @category error handling
|
|
1305
|
+
*/
|
|
1306
|
+
export declare const retry: {
|
|
1307
|
+
<A, E>(options?: {
|
|
1308
|
+
while?: Predicate<E> | undefined;
|
|
1309
|
+
times?: number | undefined;
|
|
1310
|
+
delay?: DelayFn | undefined;
|
|
1311
|
+
} | undefined): <R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1312
|
+
<A, E, R>(self: Micro<A, E, R>, options?: {
|
|
1313
|
+
while?: Predicate<E> | undefined;
|
|
1314
|
+
times?: number | undefined;
|
|
1315
|
+
delay?: DelayFn | undefined;
|
|
1316
|
+
} | undefined): Micro<A, E, R>;
|
|
1317
|
+
};
|
|
1318
|
+
/**
|
|
1319
|
+
* Add a stack trace to any failures that occur in the effect. The trace will be
|
|
1320
|
+
* added to the `traces` field of the `Failure` object.
|
|
1321
|
+
*
|
|
1322
|
+
* @since 3.4.0
|
|
1323
|
+
* @experimental
|
|
1324
|
+
* @category error handling
|
|
1325
|
+
*/
|
|
1326
|
+
export declare const withTrace: {
|
|
1327
|
+
(name: string): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1328
|
+
<A, E, R>(self: Micro<A, E, R>, name: string): Micro<A, E, R>;
|
|
1329
|
+
};
|
|
1330
|
+
/**
|
|
1331
|
+
* @since 3.4.0
|
|
1332
|
+
* @experimental
|
|
1333
|
+
* @category pattern matching
|
|
1334
|
+
*/
|
|
1335
|
+
export declare const matchFailureMicro: {
|
|
1336
|
+
<E, A2, E2, R2, A, A3, E3, R3>(options: {
|
|
1337
|
+
readonly onFailure: (failure: Failure<E>) => Micro<A2, E2, R2>;
|
|
1338
|
+
readonly onSuccess: (a: A) => Micro<A3, E3, R3>;
|
|
1339
|
+
}): <R>(self: Micro<A, E, R>) => Micro<A2 | A3, E2 | E3, R2 | R3 | R>;
|
|
1340
|
+
<A, E, R, A2, E2, R2, A3, E3, R3>(self: Micro<A, E, R>, options: {
|
|
1341
|
+
readonly onFailure: (failure: Failure<E>) => Micro<A2, E2, R2>;
|
|
1342
|
+
readonly onSuccess: (a: A) => Micro<A3, E3, R3>;
|
|
1343
|
+
}): Micro<A2 | A3, E2 | E3, R2 | R3 | R>;
|
|
1344
|
+
};
|
|
1345
|
+
/**
|
|
1346
|
+
* @since 3.4.0
|
|
1347
|
+
* @experimental
|
|
1348
|
+
* @category pattern matching
|
|
1349
|
+
*/
|
|
1350
|
+
export declare const matchFailure: {
|
|
1351
|
+
<E, A2, A, A3>(options: {
|
|
1352
|
+
readonly onFailure: (failure: Failure<E>) => A2;
|
|
1353
|
+
readonly onSuccess: (a: A) => A3;
|
|
1354
|
+
}): <R>(self: Micro<A, E, R>) => Micro<A2 | A3, never, R>;
|
|
1355
|
+
<A, E, R, A2, A3>(self: Micro<A, E, R>, options: {
|
|
1356
|
+
readonly onFailure: (failure: Failure<E>) => A2;
|
|
1357
|
+
readonly onSuccess: (a: A) => A3;
|
|
1358
|
+
}): Micro<A2 | A3, never, R>;
|
|
1359
|
+
};
|
|
1360
|
+
/**
|
|
1361
|
+
* @since 3.4.0
|
|
1362
|
+
* @experimental
|
|
1363
|
+
* @category pattern matching
|
|
1364
|
+
*/
|
|
1365
|
+
export declare const matchMicro: {
|
|
1366
|
+
<E, A2, E2, R2, A, A3, E3, R3>(options: {
|
|
1367
|
+
readonly onFailure: (e: E) => Micro<A2, E2, R2>;
|
|
1368
|
+
readonly onSuccess: (a: A) => Micro<A3, E3, R3>;
|
|
1369
|
+
}): <R>(self: Micro<A, E, R>) => Micro<A2 | A3, E2 | E3, R2 | R3 | R>;
|
|
1370
|
+
<A, E, R, A2, E2, R2, A3, E3, R3>(self: Micro<A, E, R>, options: {
|
|
1371
|
+
readonly onFailure: (e: E) => Micro<A2, E2, R2>;
|
|
1372
|
+
readonly onSuccess: (a: A) => Micro<A3, E3, R3>;
|
|
1373
|
+
}): Micro<A2 | A3, E2 | E3, R2 | R3 | R>;
|
|
1374
|
+
};
|
|
1375
|
+
/**
|
|
1376
|
+
* @since 3.4.0
|
|
1377
|
+
* @experimental
|
|
1378
|
+
* @category pattern matching
|
|
1379
|
+
*/
|
|
1380
|
+
export declare const match: {
|
|
1381
|
+
<E, A2, A, A3>(options: {
|
|
1382
|
+
readonly onFailure: (error: E) => A2;
|
|
1383
|
+
readonly onSuccess: (value: A) => A3;
|
|
1384
|
+
}): <R>(self: Micro<A, E, R>) => Micro<A2 | A3, never, R>;
|
|
1385
|
+
<A, E, R, A2, A3>(self: Micro<A, E, R>, options: {
|
|
1386
|
+
readonly onFailure: (error: E) => A2;
|
|
1387
|
+
readonly onSuccess: (value: A) => A3;
|
|
1388
|
+
}): Micro<A2 | A3, never, R>;
|
|
1389
|
+
};
|
|
1390
|
+
/**
|
|
1391
|
+
* Create a `Micro` effect that will sleep for the specified duration.
|
|
1392
|
+
*
|
|
1393
|
+
* @since 3.4.0
|
|
1394
|
+
* @experimental
|
|
1395
|
+
* @category delays & timeouts
|
|
1396
|
+
*/
|
|
1397
|
+
export declare const sleep: (millis: number) => Micro<void>;
|
|
1398
|
+
/**
|
|
1399
|
+
* Returns an effect that will delay the execution of this effect by the
|
|
1400
|
+
* specified duration.
|
|
1401
|
+
*
|
|
1402
|
+
* @since 3.4.0
|
|
1403
|
+
* @experimental
|
|
1404
|
+
* @category delays & timeouts
|
|
1405
|
+
*/
|
|
1406
|
+
export declare const delay: {
|
|
1407
|
+
(millis: number): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1408
|
+
<A, E, R>(self: Micro<A, E, R>, millis: number): Micro<A, E, R>;
|
|
1409
|
+
};
|
|
1410
|
+
/**
|
|
1411
|
+
* Returns an effect that will timeout this effect, that will execute the
|
|
1412
|
+
* fallback effect if the timeout elapses before the effect has produced a value.
|
|
1413
|
+
*
|
|
1414
|
+
* If the timeout elapses, the running effect will be safely interrupted.
|
|
1415
|
+
*
|
|
1416
|
+
* @since 3.4.0
|
|
1417
|
+
* @experimental
|
|
1418
|
+
* @category delays & timeouts
|
|
1419
|
+
*/
|
|
1420
|
+
export declare const timeoutOrElse: {
|
|
1421
|
+
<A2, E2, R2>(options: {
|
|
1422
|
+
readonly duration: number;
|
|
1423
|
+
readonly onTimeout: LazyArg<Micro<A2, E2, R2>>;
|
|
1424
|
+
}): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
|
|
1425
|
+
<A, E, R, A2, E2, R2>(self: Micro<A, E, R>, options: {
|
|
1426
|
+
readonly duration: number;
|
|
1427
|
+
readonly onTimeout: LazyArg<Micro<A2, E2, R2>>;
|
|
1428
|
+
}): Micro<A | A2, E | E2, R | R2>;
|
|
1429
|
+
};
|
|
1430
|
+
/**
|
|
1431
|
+
* Returns an effect that will timeout this effect, succeeding with a `None`
|
|
1432
|
+
* if the timeout elapses before the effect has produced a value; and `Some` of
|
|
1433
|
+
* the produced value otherwise.
|
|
1434
|
+
*
|
|
1435
|
+
* If the timeout elapses, the running effect will be safely interrupted.
|
|
1436
|
+
*
|
|
1437
|
+
* @since 3.4.0
|
|
1438
|
+
* @experimental
|
|
1439
|
+
* @category delays & timeouts
|
|
1440
|
+
*/
|
|
1441
|
+
export declare const timeout: {
|
|
1442
|
+
(millis: number): <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Option<A>, E, R>;
|
|
1443
|
+
<A, E, R>(self: Micro<A, E, R>, millis: number): Micro<Option.Option<A>, E, R>;
|
|
1444
|
+
};
|
|
1445
|
+
/**
|
|
1446
|
+
* @since 3.4.0
|
|
1447
|
+
* @experimental
|
|
1448
|
+
* @category resources & finalization
|
|
1449
|
+
*/
|
|
1450
|
+
export declare const MicroScopeTypeId: unique symbol;
|
|
1451
|
+
/**
|
|
1452
|
+
* @since 3.4.0
|
|
1453
|
+
* @experimental
|
|
1454
|
+
* @category resources & finalization
|
|
1455
|
+
*/
|
|
1456
|
+
export type MicroScopeTypeId = typeof MicroScopeTypeId;
|
|
1457
|
+
/**
|
|
1458
|
+
* @since 3.4.0
|
|
1459
|
+
* @experimental
|
|
1460
|
+
* @category resources & finalization
|
|
1461
|
+
*/
|
|
1462
|
+
export interface MicroScope {
|
|
1463
|
+
readonly [MicroScopeTypeId]: MicroScopeTypeId;
|
|
1464
|
+
readonly addFinalizer: (finalizer: (result: Result<unknown, unknown>) => Micro<void>) => Micro<void>;
|
|
1465
|
+
readonly fork: Micro<MicroScope.Closeable>;
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* @since 3.4.0
|
|
1469
|
+
* @experimental
|
|
1470
|
+
* @category resources & finalization
|
|
1471
|
+
*/
|
|
1472
|
+
export declare namespace MicroScope {
|
|
1473
|
+
/**
|
|
1474
|
+
* @since 3.4.0
|
|
1475
|
+
* @experimental
|
|
1476
|
+
* @category resources & finalization
|
|
1477
|
+
*/
|
|
1478
|
+
interface Closeable extends MicroScope {
|
|
1479
|
+
readonly close: (result: Result<any, any>) => Micro<void>;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* @since 3.4.0
|
|
1484
|
+
* @experimental
|
|
1485
|
+
* @category resources & finalization
|
|
1486
|
+
*/
|
|
1487
|
+
export declare const MicroScope: Context.Tag<MicroScope, MicroScope>;
|
|
1488
|
+
/**
|
|
1489
|
+
* @since 3.4.0
|
|
1490
|
+
* @experimental
|
|
1491
|
+
* @category resources & finalization
|
|
1492
|
+
*/
|
|
1493
|
+
export declare const scopeMake: Micro<MicroScope.Closeable>;
|
|
1494
|
+
/**
|
|
1495
|
+
* @since 3.4.0
|
|
1496
|
+
* @experimental
|
|
1497
|
+
* @category resources & finalization
|
|
1498
|
+
*/
|
|
1499
|
+
export declare const scopeUnsafeMake: () => MicroScope.Closeable;
|
|
1500
|
+
/**
|
|
1501
|
+
* Access the current `MicroScope`.
|
|
1502
|
+
*
|
|
1503
|
+
* @since 3.4.0
|
|
1504
|
+
* @experimental
|
|
1505
|
+
* @category resources & finalization
|
|
1506
|
+
*/
|
|
1507
|
+
export declare const scope: Micro<MicroScope, never, MicroScope>;
|
|
1508
|
+
/**
|
|
1509
|
+
* Provide a `MicroScope` to an effect.
|
|
1510
|
+
*
|
|
1511
|
+
* @since 3.4.0
|
|
1512
|
+
* @experimental
|
|
1513
|
+
* @category resources & finalization
|
|
1514
|
+
*/
|
|
1515
|
+
export declare const provideScope: {
|
|
1516
|
+
(scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, MicroScope>>;
|
|
1517
|
+
<A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<A, E, Exclude<R, MicroScope>>;
|
|
1518
|
+
};
|
|
1519
|
+
/**
|
|
1520
|
+
* Provide a `MicroScope` to the given effect, closing it after the effect has
|
|
1521
|
+
* finished executing.
|
|
1522
|
+
*
|
|
1523
|
+
* @since 3.4.0
|
|
1524
|
+
* @experimental
|
|
1525
|
+
* @category resources & finalization
|
|
1526
|
+
*/
|
|
1527
|
+
export declare const scoped: <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, MicroScope>>;
|
|
1528
|
+
/**
|
|
1529
|
+
* Create a resource with a cleanup `Micro` effect, ensuring the cleanup is
|
|
1530
|
+
* executed when the `MicroScope` is closed.
|
|
1531
|
+
*
|
|
1532
|
+
* @since 3.4.0
|
|
1533
|
+
* @experimental
|
|
1534
|
+
* @category resources & finalization
|
|
1535
|
+
*/
|
|
1536
|
+
export declare const acquireRelease: <A, E, R>(acquire: Micro<A, E, R>, release: (a: A, result: Result<unknown, unknown>) => Micro<void>) => Micro<A, E, R | MicroScope>;
|
|
1537
|
+
/**
|
|
1538
|
+
* Add a finalizer to the current `MicroScope`.
|
|
1539
|
+
*
|
|
1540
|
+
* @since 3.4.0
|
|
1541
|
+
* @experimental
|
|
1542
|
+
* @category resources & finalization
|
|
1543
|
+
*/
|
|
1544
|
+
export declare const addFinalizer: (finalizer: (result: Result<unknown, unknown>) => Micro<void>) => Micro<void, never, MicroScope>;
|
|
1545
|
+
/**
|
|
1546
|
+
* When the `Micro` effect is completed, run the given finalizer effect with the
|
|
1547
|
+
* `Result` of the executed effect.
|
|
1548
|
+
*
|
|
1549
|
+
* @since 3.4.0
|
|
1550
|
+
* @experimental
|
|
1551
|
+
* @category resources & finalization
|
|
1552
|
+
*/
|
|
1553
|
+
export declare const onResult: {
|
|
1554
|
+
<A, E, XE, XR>(f: (result: Result<A, E>) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1555
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, f: (result: Result<A, E>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1556
|
+
};
|
|
1557
|
+
/**
|
|
1558
|
+
* When the `Micro` effect is completed, run the given finalizer effect if it
|
|
1559
|
+
* matches the specified predicate.
|
|
1560
|
+
*
|
|
1561
|
+
* @since 3.4.0
|
|
1562
|
+
* @experimental
|
|
1563
|
+
* @category resources & finalization
|
|
1564
|
+
*/
|
|
1565
|
+
export declare const onResultIf: {
|
|
1566
|
+
<A, E, XE, XR, B extends Result<A, E>>(refinement: Refinement<Result<A, E>, B>, f: (result: B) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1567
|
+
<A, E, XE, XR>(predicate: Predicate<Result<NoInfer<A>, NoInfer<E>>>, f: (result: Result<NoInfer<A>, NoInfer<E>>) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1568
|
+
<A, E, R, XE, XR, B extends Result<A, E>>(self: Micro<A, E, R>, refinement: Refinement<Result<A, E>, B>, f: (result: B) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1569
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, predicate: Predicate<Result<NoInfer<A>, NoInfer<E>>>, f: (result: Result<NoInfer<A>, NoInfer<E>>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1570
|
+
};
|
|
1571
|
+
/**
|
|
1572
|
+
* Regardless of the result of the this `Micro` effect, run the finalizer effect.
|
|
1573
|
+
*
|
|
1574
|
+
* @since 3.4.0
|
|
1575
|
+
* @experimental
|
|
1576
|
+
* @category resources & finalization
|
|
1577
|
+
*/
|
|
1578
|
+
export declare const ensuring: {
|
|
1579
|
+
<XE, XR>(finalizer: Micro<void, XE, XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1580
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, finalizer: Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1581
|
+
};
|
|
1582
|
+
/**
|
|
1583
|
+
* When the `Micro` effect fails, run the given finalizer effect with the
|
|
1584
|
+
* `Failure` of the executed effect.
|
|
1585
|
+
*
|
|
1586
|
+
* @since 3.4.0
|
|
1587
|
+
* @experimental
|
|
1588
|
+
* @category resources & finalization
|
|
1589
|
+
*/
|
|
1590
|
+
export declare const onFailure: {
|
|
1591
|
+
<A, E, XE, XR>(f: (failure: Failure<NoInfer<E>>) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1592
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, f: (failure: Failure<NoInfer<E>>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1593
|
+
};
|
|
1594
|
+
/**
|
|
1595
|
+
* If this `Micro` effect is aborted, run the finalizer effect.
|
|
1596
|
+
*
|
|
1597
|
+
* @since 3.4.0
|
|
1598
|
+
* @experimental
|
|
1599
|
+
* @category resources & finalization
|
|
1600
|
+
*/
|
|
1601
|
+
export declare const onAbort: {
|
|
1602
|
+
<XE, XR>(finalizer: Micro<void, XE, XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1603
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, finalizer: Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1604
|
+
};
|
|
1605
|
+
/**
|
|
1606
|
+
* Acquire a resource, use it, and then release the resource when the `use`
|
|
1607
|
+
* effect has completed.
|
|
1608
|
+
*
|
|
1609
|
+
* @since 3.4.0
|
|
1610
|
+
* @experimental
|
|
1611
|
+
* @category resources & finalization
|
|
1612
|
+
*/
|
|
1613
|
+
export declare const acquireUseRelease: <Resource, E, R, A, E2, R2, E3, R3>(acquire: Micro<Resource, E, R>, use: (a: Resource) => Micro<A, E2, R2>, release: (a: Resource, result: Result<A, E2>) => Micro<void, E3, R3>) => Micro<A, E | E2 | E3, R | R2 | R3>;
|
|
1614
|
+
/**
|
|
1615
|
+
* Abort the current `Micro` effect.
|
|
1616
|
+
*
|
|
1617
|
+
* @since 3.4.0
|
|
1618
|
+
* @experimental
|
|
1619
|
+
* @category interruption
|
|
1620
|
+
*/
|
|
1621
|
+
export declare const abort: Micro<never>;
|
|
1622
|
+
/**
|
|
1623
|
+
* Wrap the given `Micro` effect in an uninterruptible region, preventing the
|
|
1624
|
+
* effect from being aborted.
|
|
1625
|
+
*
|
|
1626
|
+
* @since 3.4.0
|
|
1627
|
+
* @experimental
|
|
1628
|
+
* @category interruption
|
|
1629
|
+
*/
|
|
1630
|
+
export declare const uninterruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1631
|
+
/**
|
|
1632
|
+
* Wrap the given `Micro` effect in an uninterruptible region, preventing the
|
|
1633
|
+
* effect from being aborted.
|
|
1634
|
+
*
|
|
1635
|
+
* You can use the `restore` function to restore a `Micro` effect to the
|
|
1636
|
+
* interruptibility state before the `uninterruptibleMask` was applied.
|
|
1637
|
+
*
|
|
1638
|
+
* @since 3.4.0
|
|
1639
|
+
* @experimental
|
|
1640
|
+
* @category interruption
|
|
1641
|
+
* @example
|
|
1642
|
+
* import * as Micro from "effect/Micro"
|
|
1643
|
+
*
|
|
1644
|
+
* Micro.uninterruptibleMask((restore) =>
|
|
1645
|
+
* Micro.sleep(1000).pipe( // uninterruptible
|
|
1646
|
+
* Micro.andThen(restore(Micro.sleep(1000))) // interruptible
|
|
1647
|
+
* )
|
|
1648
|
+
* )
|
|
1649
|
+
*/
|
|
1650
|
+
export declare const uninterruptibleMask: <A, E, R>(f: (restore: <A_1, E_1, R_1>(effect: Micro<A_1, E_1, R_1>) => Micro<A_1, E_1, R_1>) => Micro<A, E, R>) => Micro<A, E, R>;
|
|
1651
|
+
/**
|
|
1652
|
+
* Wrap the given `Micro` effect in an interruptible region, allowing the effect
|
|
1653
|
+
* to be aborted.
|
|
1654
|
+
*
|
|
1655
|
+
* @since 3.4.0
|
|
1656
|
+
* @experimental
|
|
1657
|
+
* @category interruption
|
|
1658
|
+
*/
|
|
1659
|
+
export declare const interruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1660
|
+
/**
|
|
1661
|
+
* @since 3.4.0
|
|
1662
|
+
* @experimental
|
|
1663
|
+
*/
|
|
1664
|
+
export declare namespace All {
|
|
1665
|
+
/**
|
|
1666
|
+
* @since 3.4.0
|
|
1667
|
+
* @experimental
|
|
1668
|
+
*/
|
|
1669
|
+
type MicroAny = Micro<any, any, any>;
|
|
1670
|
+
/**
|
|
1671
|
+
* @since 3.4.0
|
|
1672
|
+
* @experimental
|
|
1673
|
+
*/
|
|
1674
|
+
type ReturnIterable<T extends Iterable<MicroAny>, Discard extends boolean> = [T] extends [
|
|
1675
|
+
Iterable<Micro<infer A, infer E, infer R>>
|
|
1676
|
+
] ? Micro<Discard extends true ? void : Array<A>, E, R> : never;
|
|
1677
|
+
/**
|
|
1678
|
+
* @since 3.4.0
|
|
1679
|
+
* @experimental
|
|
1680
|
+
*/
|
|
1681
|
+
type ReturnTuple<T extends ReadonlyArray<unknown>, Discard extends boolean> = Micro<Discard extends true ? void : T[number] extends never ? [] : {
|
|
1682
|
+
-readonly [K in keyof T]: T[K] extends Micro<infer _A, infer _E, infer _R> ? _A : never;
|
|
1683
|
+
}, T[number] extends never ? never : T[number] extends Micro<infer _A, infer _E, infer _R> ? _E : never, T[number] extends never ? never : T[number] extends Micro<infer _A, infer _E, infer _R> ? _R : never> extends infer X ? X : never;
|
|
1684
|
+
/**
|
|
1685
|
+
* @since 3.4.0
|
|
1686
|
+
* @experimental
|
|
1687
|
+
*/
|
|
1688
|
+
type ReturnObject<T, Discard extends boolean> = [T] extends [{
|
|
1689
|
+
[K: string]: MicroAny;
|
|
1690
|
+
}] ? Micro<Discard extends true ? void : {
|
|
1691
|
+
-readonly [K in keyof T]: [T[K]] extends [Micro<infer _A, infer _E, infer _R>] ? _A : never;
|
|
1692
|
+
}, keyof T extends never ? never : T[keyof T] extends Micro<infer _A, infer _E, infer _R> ? _E : never, keyof T extends never ? never : T[keyof T] extends Micro<infer _A, infer _E, infer _R> ? _R : never> : never;
|
|
1693
|
+
/**
|
|
1694
|
+
* @since 3.4.0
|
|
1695
|
+
* @experimental
|
|
1696
|
+
*/
|
|
1697
|
+
type IsDiscard<A> = [Extract<A, {
|
|
1698
|
+
readonly discard: true;
|
|
1699
|
+
}>] extends [never] ? false : true;
|
|
1700
|
+
/**
|
|
1701
|
+
* @since 3.4.0
|
|
1702
|
+
* @experimental
|
|
1703
|
+
*/
|
|
1704
|
+
type Return<Arg extends Iterable<MicroAny> | Record<string, MicroAny>, O extends {
|
|
1705
|
+
readonly concurrency?: Concurrency | undefined;
|
|
1706
|
+
readonly discard?: boolean | undefined;
|
|
1707
|
+
}> = [Arg] extends [ReadonlyArray<MicroAny>] ? ReturnTuple<Arg, IsDiscard<O>> : [Arg] extends [Iterable<MicroAny>] ? ReturnIterable<Arg, IsDiscard<O>> : [Arg] extends [Record<string, MicroAny>] ? ReturnObject<Arg, IsDiscard<O>> : never;
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Runs all the provided effects in sequence respecting the structure provided in input.
|
|
1711
|
+
*
|
|
1712
|
+
* Supports multiple arguments, a single argument tuple / array or record / struct.
|
|
1713
|
+
*
|
|
1714
|
+
* @since 3.4.0
|
|
1715
|
+
* @experimental
|
|
1716
|
+
* @category collecting & elements
|
|
1717
|
+
*/
|
|
1718
|
+
export declare const all: <const Arg extends Iterable<Micro<any, any, any>> | Record<string, Micro<any, any, any>>, O extends {
|
|
1719
|
+
readonly concurrency?: Concurrency | undefined;
|
|
1720
|
+
readonly discard?: boolean | undefined;
|
|
1721
|
+
}>(arg: Arg, options?: O) => All.Return<Arg, O>;
|
|
1722
|
+
/**
|
|
1723
|
+
* For each element of the provided iterable, run the effect and collect the results.
|
|
1724
|
+
*
|
|
1725
|
+
* If the `discard` option is set to `true`, the results will be discarded and
|
|
1726
|
+
* the effect will return `void`.
|
|
1727
|
+
*
|
|
1728
|
+
* The `concurrency` option can be set to control how many effects are run in
|
|
1729
|
+
* parallel. By default, the effects are run sequentially.
|
|
1730
|
+
*
|
|
1731
|
+
* @since 3.4.0
|
|
1732
|
+
* @experimental
|
|
1733
|
+
* @category collecting & elements
|
|
1734
|
+
*/
|
|
1735
|
+
export declare const forEach: {
|
|
1736
|
+
<A, B, E, R>(iterable: Iterable<A>, f: (a: A, index: number) => Micro<B, E, R>, options?: {
|
|
1737
|
+
readonly concurrency?: Concurrency | undefined;
|
|
1738
|
+
readonly discard?: false | undefined;
|
|
1739
|
+
}): Micro<Array<B>, E, R>;
|
|
1740
|
+
<A, B, E, R>(iterable: Iterable<A>, f: (a: A, index: number) => Micro<B, E, R>, options: {
|
|
1741
|
+
readonly concurrency?: Concurrency | undefined;
|
|
1742
|
+
readonly discard: true;
|
|
1743
|
+
}): Micro<void, E, R>;
|
|
1744
|
+
};
|
|
1745
|
+
/**
|
|
1746
|
+
* Effectfully filter the elements of the provided iterable.
|
|
1747
|
+
*
|
|
1748
|
+
* Use the `concurrency` option to control how many elements are processed in parallel.
|
|
1749
|
+
*
|
|
1750
|
+
* @since 3.4.0
|
|
1751
|
+
* @experimental
|
|
1752
|
+
* @category collecting & elements
|
|
1753
|
+
*/
|
|
1754
|
+
export declare const filter: <A, E, R>(iterable: Iterable<A>, f: (a: NoInfer<A>) => Micro<boolean, E, R>, options?: {
|
|
1755
|
+
readonly concurrency?: Concurrency | undefined;
|
|
1756
|
+
readonly negate?: boolean | undefined;
|
|
1757
|
+
}) => Micro<Array<A>, E, R>;
|
|
1758
|
+
/**
|
|
1759
|
+
* Effectfully filter the elements of the provided iterable.
|
|
1760
|
+
*
|
|
1761
|
+
* Use the `concurrency` option to control how many elements are processed in parallel.
|
|
1762
|
+
*
|
|
1763
|
+
* @since 3.4.0
|
|
1764
|
+
* @experimental
|
|
1765
|
+
* @category collecting & elements
|
|
1766
|
+
*/
|
|
1767
|
+
export declare const filterMap: <A, B, E, R>(iterable: Iterable<A>, f: (a: NoInfer<A>) => Micro<Option.Option<B>, E, R>, options?: {
|
|
1768
|
+
readonly concurrency?: Concurrency | undefined;
|
|
1769
|
+
}) => Micro<Array<B>, E, R>;
|
|
1770
|
+
/**
|
|
1771
|
+
* Start a do notation block.
|
|
1772
|
+
*
|
|
1773
|
+
* @since 3.4.0
|
|
1774
|
+
* @experimental
|
|
1775
|
+
* @category do notation
|
|
1776
|
+
*/
|
|
1777
|
+
export declare const Do: Micro<{}>;
|
|
1778
|
+
/**
|
|
1779
|
+
* Bind the success value of this `Micro` effect to the provided name.
|
|
1780
|
+
*
|
|
1781
|
+
* @since 3.4.0
|
|
1782
|
+
* @experimental
|
|
1783
|
+
* @category do notation
|
|
1784
|
+
*/
|
|
1785
|
+
export declare const bindTo: {
|
|
1786
|
+
<N extends string>(name: N): <A, E, R>(self: Micro<A, E, R>) => Micro<{
|
|
1787
|
+
[K in N]: A;
|
|
1788
|
+
}, E, R>;
|
|
1789
|
+
<A, E, R, N extends string>(self: Micro<A, E, R>, name: N): Micro<{
|
|
1790
|
+
[K in N]: A;
|
|
1791
|
+
}, E, R>;
|
|
1792
|
+
};
|
|
1793
|
+
/**
|
|
1794
|
+
* Bind the success value of this `Micro` effect to the provided name.
|
|
1795
|
+
*
|
|
1796
|
+
* @since 3.4.0
|
|
1797
|
+
* @experimental
|
|
1798
|
+
* @category do notation
|
|
1799
|
+
*/
|
|
1800
|
+
export declare const bind: {
|
|
1801
|
+
<N extends string, A extends Record<string, any>, B, E2, R2>(name: N, f: (a: A) => Micro<B, E2, R2>): <E, R>(self: Micro<A, E, R>) => Micro<Simplify<Omit<A, N> & {
|
|
1802
|
+
[K in N]: B;
|
|
1803
|
+
}>, E | E2, R | R2>;
|
|
1804
|
+
<A extends Record<string, any>, E, R, B, E2, R2, N extends string>(self: Micro<A, E, R>, name: N, f: (a: A) => Micro<B, E2, R2>): Micro<Simplify<Omit<A, N> & {
|
|
1805
|
+
[K in N]: B;
|
|
1806
|
+
}>, E | E2, R | R2>;
|
|
1807
|
+
};
|
|
1808
|
+
declare const let_: {
|
|
1809
|
+
<N extends string, A extends Record<string, any>, B>(name: N, f: (a: A) => B): <E, R>(self: Micro<A, E, R>) => Micro<Simplify<Omit<A, N> & {
|
|
1810
|
+
[K in N]: B;
|
|
1811
|
+
}>, E, R>;
|
|
1812
|
+
<A extends Record<string, any>, E, R, B, N extends string>(self: Micro<A, E, R>, name: N, f: (a: A) => B): Micro<Simplify<Omit<A, N> & {
|
|
1813
|
+
[K in N]: B;
|
|
1814
|
+
}>, E, R>;
|
|
1815
|
+
};
|
|
1816
|
+
export {
|
|
1817
|
+
/**
|
|
1818
|
+
* Bind the result of a synchronous computation to the given name.
|
|
1819
|
+
*
|
|
1820
|
+
* @since 3.4.0
|
|
1821
|
+
* @experimental
|
|
1822
|
+
* @category do notation
|
|
1823
|
+
*/
|
|
1824
|
+
let_ as let };
|
|
1825
|
+
/**
|
|
1826
|
+
* @since 3.4.0
|
|
1827
|
+
* @experimental
|
|
1828
|
+
* @category handle & forking
|
|
1829
|
+
*/
|
|
1830
|
+
export declare const HandleTypeId: unique symbol;
|
|
1831
|
+
/**
|
|
1832
|
+
* @since 3.4.0
|
|
1833
|
+
* @experimental
|
|
1834
|
+
* @category handle & forking
|
|
1835
|
+
*/
|
|
1836
|
+
export type HandleTypeId = typeof HandleTypeId;
|
|
1837
|
+
/**
|
|
1838
|
+
* @since 3.4.0
|
|
1839
|
+
* @experimental
|
|
1840
|
+
* @category handle & forking
|
|
1841
|
+
*/
|
|
1842
|
+
export interface Handle<A, E = never> {
|
|
1843
|
+
readonly [HandleTypeId]: HandleTypeId;
|
|
1844
|
+
readonly await: Micro<Result<A, E>>;
|
|
1845
|
+
readonly join: Micro<A, E>;
|
|
1846
|
+
readonly abort: Micro<Result<A, E>>;
|
|
1847
|
+
readonly unsafeAbort: () => void;
|
|
1848
|
+
readonly addObserver: (observer: (result: Result<A, E>) => void) => void;
|
|
1849
|
+
readonly removeObserver: (observer: (result: Result<A, E>) => void) => void;
|
|
1850
|
+
readonly unsafePoll: () => Result<A, E> | null;
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* @since 3.4.0
|
|
1854
|
+
* @experimental
|
|
1855
|
+
* @category handle & forking
|
|
1856
|
+
*/
|
|
1857
|
+
export declare const isHandle: (u: unknown) => u is Handle<unknown, unknown>;
|
|
1858
|
+
/**
|
|
1859
|
+
* Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
|
|
1860
|
+
* aborted.
|
|
1861
|
+
*
|
|
1862
|
+
* When the parent `Micro` finishes, this `Micro` will be aborted.
|
|
1863
|
+
*
|
|
1864
|
+
* @since 3.4.0
|
|
1865
|
+
* @experimental
|
|
1866
|
+
* @category handle & forking
|
|
1867
|
+
*/
|
|
1868
|
+
export declare const fork: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R>;
|
|
1869
|
+
/**
|
|
1870
|
+
* Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
|
|
1871
|
+
* aborted.
|
|
1872
|
+
*
|
|
1873
|
+
* It will not be aborted when the parent `Micro` finishes.
|
|
1874
|
+
*
|
|
1875
|
+
* @since 3.4.0
|
|
1876
|
+
* @experimental
|
|
1877
|
+
* @category handle & forking
|
|
1878
|
+
*/
|
|
1879
|
+
export declare const forkDaemon: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R>;
|
|
1880
|
+
/**
|
|
1881
|
+
* Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
|
|
1882
|
+
* aborted.
|
|
1883
|
+
*
|
|
1884
|
+
* The lifetime of the handle will be attached to the provided `MicroScope`.
|
|
1885
|
+
*
|
|
1886
|
+
* @since 3.4.0
|
|
1887
|
+
* @experimental
|
|
1888
|
+
* @category handle & forking
|
|
1889
|
+
*/
|
|
1890
|
+
export declare const forkIn: {
|
|
1891
|
+
(scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R>;
|
|
1892
|
+
<A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<Handle<A, E>, never, R>;
|
|
1893
|
+
};
|
|
1894
|
+
/**
|
|
1895
|
+
* Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
|
|
1896
|
+
* aborted.
|
|
1897
|
+
*
|
|
1898
|
+
* The lifetime of the handle will be attached to the current `MicroScope`.
|
|
1899
|
+
*
|
|
1900
|
+
* @since 3.4.0
|
|
1901
|
+
* @experimental
|
|
1902
|
+
* @category handle & forking
|
|
1903
|
+
*/
|
|
1904
|
+
export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R | MicroScope>;
|
|
1905
|
+
/**
|
|
1906
|
+
* Execute the `Micro` effect and return a `Handle` that can be awaited, joined,
|
|
1907
|
+
* or aborted.
|
|
1908
|
+
*
|
|
1909
|
+
* You can listen for the result by adding an observer using the handle's
|
|
1910
|
+
* `addObserver` method.
|
|
1911
|
+
*
|
|
1912
|
+
* @since 3.4.0
|
|
1913
|
+
* @experimental
|
|
1914
|
+
* @category execution
|
|
1915
|
+
* @example
|
|
1916
|
+
* import * as Micro from "effect/Micro"
|
|
1917
|
+
*
|
|
1918
|
+
* const handle = Micro.succeed(42).pipe(
|
|
1919
|
+
* Micro.delay(1000),
|
|
1920
|
+
* Micro.runFork
|
|
1921
|
+
* )
|
|
1922
|
+
*
|
|
1923
|
+
* handle.addObserver((result) => {
|
|
1924
|
+
* console.log(result)
|
|
1925
|
+
* })
|
|
1926
|
+
*/
|
|
1927
|
+
export declare const runFork: <A, E>(effect: Micro<A, E>, options?: {
|
|
1928
|
+
readonly signal?: AbortSignal | undefined;
|
|
1929
|
+
} | undefined) => Handle<A, E>;
|
|
1930
|
+
/**
|
|
1931
|
+
* Execute the `Micro` effect and return a `Promise` that resolves with the
|
|
1932
|
+
* `Result` of the computation.
|
|
1933
|
+
*
|
|
1934
|
+
* @since 3.4.0
|
|
1935
|
+
* @experimental
|
|
1936
|
+
* @category execution
|
|
1937
|
+
*/
|
|
1938
|
+
export declare const runPromiseResult: <A, E>(effect: Micro<A, E>, options?: {
|
|
1939
|
+
readonly signal?: AbortSignal | undefined;
|
|
1940
|
+
} | undefined) => Promise<Result<A, E>>;
|
|
1941
|
+
/**
|
|
1942
|
+
* Execute the `Micro` effect and return a `Promise` that resolves with the
|
|
1943
|
+
* successful value of the computation.
|
|
1944
|
+
*
|
|
1945
|
+
* @since 3.4.0
|
|
1946
|
+
* @experimental
|
|
1947
|
+
* @category execution
|
|
1948
|
+
*/
|
|
1949
|
+
export declare const runPromise: <A, E>(effect: Micro<A, E>, options?: {
|
|
1950
|
+
readonly signal?: AbortSignal | undefined;
|
|
1951
|
+
} | undefined) => Promise<A>;
|
|
1952
|
+
/**
|
|
1953
|
+
* Attempt to execute the `Micro` effect synchronously and return the `Result`.
|
|
1954
|
+
*
|
|
1955
|
+
* If any asynchronous effects are encountered, the function will return a
|
|
1956
|
+
* FailureUnexpected containing the `Handle`.
|
|
1957
|
+
*
|
|
1958
|
+
* @since 3.4.0
|
|
1959
|
+
* @experimental
|
|
1960
|
+
* @category execution
|
|
1961
|
+
*/
|
|
1962
|
+
export declare const runSyncResult: <A, E>(effect: Micro<A, E>) => Result<A, E>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Attempt to execute the `Micro` effect synchronously and return the success
|
|
1965
|
+
* value.
|
|
1966
|
+
*
|
|
1967
|
+
* @since 3.4.0
|
|
1968
|
+
* @experimental
|
|
1969
|
+
* @category execution
|
|
1970
|
+
*/
|
|
1971
|
+
export declare const runSync: <A, E>(effect: Micro<A, E>) => A;
|
|
1972
|
+
/**
|
|
1973
|
+
* @since 3.4.0
|
|
1974
|
+
* @experimental
|
|
1975
|
+
* @category errors
|
|
1976
|
+
*/
|
|
1977
|
+
export interface YieldableError extends Pipeable, Inspectable, Readonly<Error> {
|
|
1978
|
+
readonly [EffectTypeId]: Effect.VarianceStruct<never, this, never>;
|
|
1979
|
+
readonly [StreamTypeId]: Stream.VarianceStruct<never, this, never>;
|
|
1980
|
+
readonly [SinkTypeId]: Sink.VarianceStruct<never, unknown, never, this, never>;
|
|
1981
|
+
readonly [ChannelTypeId]: Channel.VarianceStruct<never, unknown, this, unknown, never, unknown, never>;
|
|
1982
|
+
readonly [TypeId]: Micro.Variance<never, this, never>;
|
|
1983
|
+
readonly [runSymbol]: (env: Env<any>, onResult: (result: Result<never, this>) => void) => void;
|
|
1984
|
+
[Symbol.iterator](): MicroIterator<Micro<never, this, never>>;
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* @since 3.4.0
|
|
1988
|
+
* @experimental
|
|
1989
|
+
* @category errors
|
|
1990
|
+
*/
|
|
1991
|
+
export declare const Error: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : {
|
|
1992
|
+
readonly [P in keyof A]: A[P];
|
|
1993
|
+
}) => YieldableError & Readonly<A>;
|
|
1994
|
+
/**
|
|
1995
|
+
* @since 3.4.0
|
|
1996
|
+
* @experimental
|
|
1997
|
+
* @category errors
|
|
1998
|
+
*/
|
|
1999
|
+
export declare const TaggedError: <Tag extends string>(tag: Tag) => new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & {
|
|
2000
|
+
readonly _tag: Tag;
|
|
2001
|
+
} & Readonly<A>;
|
|
2002
|
+
//# sourceMappingURL=Micro.d.ts.map
|