effect 4.0.0-beta.82 → 4.0.0-beta.84
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/dist/Array.d.ts +64 -64
- package/dist/Array.js +26 -26
- package/dist/Cache.d.ts +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cause.d.ts +68 -68
- package/dist/Cause.js +47 -47
- package/dist/Channel.d.ts +5 -5
- package/dist/Channel.js +3 -3
- package/dist/Clock.d.ts +1 -1
- package/dist/Clock.js +1 -1
- package/dist/Combiner.d.ts +9 -9
- package/dist/Combiner.js +8 -8
- package/dist/Config.d.ts +15 -94
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +22 -70
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +58 -74
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +66 -41
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +1 -1
- package/dist/Console.js +1 -1
- package/dist/Data.d.ts +15 -15
- package/dist/Data.js +3 -3
- package/dist/DateTime.d.ts +6 -6
- package/dist/DateTime.js +2 -2
- package/dist/Duration.d.ts +3 -3
- package/dist/Duration.js +3 -3
- package/dist/Effect.d.ts +84 -45
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +72 -33
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +7 -7
- package/dist/Equal.js +5 -5
- package/dist/Equivalence.d.ts +17 -17
- package/dist/Equivalence.js +13 -13
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.js +3 -3
- package/dist/Formatter.d.ts +5 -5
- package/dist/Formatter.js +4 -4
- package/dist/Function.d.ts +10 -10
- package/dist/Function.js +3 -3
- package/dist/HashMap.d.ts +3 -3
- package/dist/HashMap.js +1 -1
- package/dist/Iterable.d.ts +6 -6
- package/dist/Iterable.js +2 -2
- package/dist/JsonPatch.d.ts +2 -2
- package/dist/Layer.d.ts +1 -1
- package/dist/Layer.js +1 -1
- package/dist/Logger.d.ts +1 -1
- package/dist/Logger.js +1 -1
- package/dist/Match.d.ts +8 -8
- package/dist/Match.js +8 -8
- package/dist/Metric.d.ts +3 -3
- package/dist/Metric.js +3 -3
- package/dist/Optic.d.ts +30 -30
- package/dist/Optic.js +12 -12
- package/dist/Option.d.ts +7 -7
- package/dist/Option.js +7 -7
- package/dist/Order.d.ts +23 -23
- package/dist/Order.js +20 -20
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.js +1 -1
- package/dist/Predicate.d.ts +88 -88
- package/dist/Predicate.js +47 -47
- package/dist/PubSub.d.ts +3 -3
- package/dist/PubSub.js +3 -3
- package/dist/Reducer.d.ts +1 -1
- package/dist/Reducer.js +1 -1
- package/dist/Result.d.ts +18 -18
- package/dist/Result.js +8 -8
- package/dist/Runtime.d.ts +1 -1
- package/dist/Runtime.js +1 -1
- package/dist/Schema.d.ts +265 -120
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +285 -116
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +13 -9
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +48 -48
- package/dist/SchemaGetter.js +44 -44
- package/dist/SchemaIssue.d.ts +3 -3
- package/dist/SchemaIssue.js +3 -3
- package/dist/SchemaParser.d.ts +122 -22
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +186 -50
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +96 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +20 -20
- package/dist/SchemaTransformation.js +18 -18
- package/dist/Stream.d.ts +3 -3
- package/dist/Stream.js +2 -2
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +1 -1
- package/dist/String.js +1 -1
- package/dist/Struct.d.ts +1 -1
- package/dist/Struct.js +1 -1
- package/dist/Types.d.ts +13 -13
- package/dist/internal/effect.js +23 -10
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/cause.d.ts +2 -0
- package/dist/internal/schema/cause.d.ts.map +1 -0
- package/dist/internal/schema/cause.js +24 -0
- package/dist/internal/schema/cause.js.map +1 -0
- package/dist/internal/schema/schema.d.ts +8 -4
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +21 -8
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +3 -3
- package/dist/testing/TestSchema.js +1 -1
- package/dist/unstable/ai/AiError.d.ts +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.js +1 -1
- package/dist/unstable/cli/Prompt.js +2 -2
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +39 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +3 -4
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +15 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +1 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +1 -0
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +65 -65
- package/src/Cache.ts +1 -1
- package/src/Cause.ts +68 -68
- package/src/Channel.ts +5 -5
- package/src/Clock.ts +1 -1
- package/src/Combiner.ts +9 -9
- package/src/Config.ts +40 -108
- package/src/ConfigProvider.ts +139 -100
- package/src/Console.ts +1 -1
- package/src/Data.ts +15 -15
- package/src/DateTime.ts +6 -6
- package/src/Duration.ts +3 -3
- package/src/Effect.ts +89 -45
- package/src/Equal.ts +7 -7
- package/src/Equivalence.ts +17 -17
- package/src/Exit.ts +3 -3
- package/src/Formatter.ts +5 -5
- package/src/Function.ts +10 -10
- package/src/HashMap.ts +3 -3
- package/src/Iterable.ts +6 -6
- package/src/JsonPatch.ts +2 -2
- package/src/Layer.ts +1 -1
- package/src/Logger.ts +1 -1
- package/src/Match.ts +8 -8
- package/src/Metric.ts +3 -3
- package/src/Optic.ts +30 -30
- package/src/Option.ts +7 -7
- package/src/Order.ts +23 -23
- package/src/Pool.ts +1 -1
- package/src/Predicate.ts +88 -88
- package/src/PubSub.ts +3 -3
- package/src/Reducer.ts +1 -1
- package/src/Result.ts +20 -20
- package/src/Runtime.ts +1 -1
- package/src/Schema.ts +314 -131
- package/src/SchemaAST.ts +20 -11
- package/src/SchemaGetter.ts +48 -48
- package/src/SchemaIssue.ts +3 -3
- package/src/SchemaParser.ts +197 -58
- package/src/SchemaRepresentation.ts +73 -3
- package/src/SchemaTransformation.ts +20 -20
- package/src/Stream.ts +4 -4
- package/src/String.ts +1 -1
- package/src/Struct.ts +1 -1
- package/src/Types.ts +13 -13
- package/src/internal/effect.ts +29 -10
- package/src/internal/schema/cause.ts +26 -0
- package/src/internal/schema/schema.ts +36 -10
- package/src/testing/TestSchema.ts +3 -3
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/cli/Prompt.ts +1 -1
- package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
- package/src/unstable/httpapi/HttpApiSchema.ts +18 -6
- package/src/unstable/rpc/Rpc.ts +1 -1
- package/src/unstable/rpc/RpcGroup.ts +3 -4
- package/src/unstable/sql/SqlResolver.ts +15 -2
- package/src/unstable/workflow/Activity.ts +2 -0
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
package/dist/Metric.d.ts
CHANGED
|
@@ -1554,7 +1554,7 @@ export declare namespace Metric {
|
|
|
1554
1554
|
/**
|
|
1555
1555
|
* Service key for the current metric attributes context.
|
|
1556
1556
|
*
|
|
1557
|
-
* **Example** (
|
|
1557
|
+
* **Example** (Accessing the current metric attributes key)
|
|
1558
1558
|
*
|
|
1559
1559
|
* ```ts
|
|
1560
1560
|
* import { Data, Effect, Metric } from "effect"
|
|
@@ -3551,7 +3551,7 @@ export declare const exponentialBoundaries: (options: {
|
|
|
3551
3551
|
/**
|
|
3552
3552
|
* Service key for the fiber runtime metrics service.
|
|
3553
3553
|
*
|
|
3554
|
-
* **Example** (
|
|
3554
|
+
* **Example** (Accessing the fiber runtime metrics key)
|
|
3555
3555
|
*
|
|
3556
3556
|
* ```ts
|
|
3557
3557
|
* import { Data, Effect, Layer, Metric } from "effect"
|
|
@@ -3691,7 +3691,7 @@ export declare const FiberRuntimeMetrics: Context.Reference<FiberRuntimeMetricsS
|
|
|
3691
3691
|
/**
|
|
3692
3692
|
* Default implementation of the fiber runtime metrics service.
|
|
3693
3693
|
*
|
|
3694
|
-
* **Example** (
|
|
3694
|
+
* **Example** (Accessing the default fiber metrics implementation)
|
|
3695
3695
|
*
|
|
3696
3696
|
* ```ts
|
|
3697
3697
|
* import { Data, Effect, Layer, Metric } from "effect"
|
package/dist/Metric.js
CHANGED
|
@@ -24,7 +24,7 @@ import * as _String from "./String.js";
|
|
|
24
24
|
/**
|
|
25
25
|
* Service key for the current metric attributes context.
|
|
26
26
|
*
|
|
27
|
-
* **Example** (
|
|
27
|
+
* **Example** (Accessing the current metric attributes key)
|
|
28
28
|
*
|
|
29
29
|
* ```ts
|
|
30
30
|
* import { Data, Effect, Metric } from "effect"
|
|
@@ -1675,7 +1675,7 @@ const fiberFailures = /*#__PURE__*/counter("child_fiber_failures", {
|
|
|
1675
1675
|
/**
|
|
1676
1676
|
* Service key for the fiber runtime metrics service.
|
|
1677
1677
|
*
|
|
1678
|
-
* **Example** (
|
|
1678
|
+
* **Example** (Accessing the fiber runtime metrics key)
|
|
1679
1679
|
*
|
|
1680
1680
|
* ```ts
|
|
1681
1681
|
* import { Data, Effect, Layer, Metric } from "effect"
|
|
@@ -1774,7 +1774,7 @@ export const FiberRuntimeMetrics = /*#__PURE__*/Context.Reference(InternalMetric
|
|
|
1774
1774
|
/**
|
|
1775
1775
|
* Default implementation of the fiber runtime metrics service.
|
|
1776
1776
|
*
|
|
1777
|
-
* **Example** (
|
|
1777
|
+
* **Example** (Accessing the default fiber metrics implementation)
|
|
1778
1778
|
*
|
|
1779
1779
|
* ```ts
|
|
1780
1780
|
* import { Data, Effect, Layer, Metric } from "effect"
|
package/dist/Optic.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ import type { IsUnion } from "./Types.ts";
|
|
|
32
32
|
* - `get(set(a)) === a` and `set(get(s))` equals `s` (round-trip laws).
|
|
33
33
|
* - Extends both {@link Lens} and {@link Prism}.
|
|
34
34
|
*
|
|
35
|
-
* **Example** (Celsius
|
|
35
|
+
* **Example** (Converting between Celsius and Fahrenheit)
|
|
36
36
|
*
|
|
37
37
|
* ```ts
|
|
38
38
|
* import { Optic } from "effect"
|
|
@@ -70,7 +70,7 @@ export interface Iso<in out S, in out A> extends Lens<S, A>, Prism<S, A> {
|
|
|
70
70
|
*
|
|
71
71
|
* The returned optic can be composed with any other optic.
|
|
72
72
|
*
|
|
73
|
-
* **Example** (
|
|
73
|
+
* **Example** (Wrapping and unwrapping a branded type)
|
|
74
74
|
*
|
|
75
75
|
* ```ts
|
|
76
76
|
* import { Optic } from "effect"
|
|
@@ -111,7 +111,7 @@ export declare function makeIso<S, A>(get: (s: S) => A, set: (a: A) => S): Iso<S
|
|
|
111
111
|
* - Composing a Lens with a {@link Prism} or {@link Optional} produces an
|
|
112
112
|
* {@link Optional}.
|
|
113
113
|
*
|
|
114
|
-
* **Example** (
|
|
114
|
+
* **Example** (Focusing on a struct field)
|
|
115
115
|
*
|
|
116
116
|
* ```ts
|
|
117
117
|
* import { Optic } from "effect"
|
|
@@ -147,7 +147,7 @@ export interface Lens<in out S, in out A> extends Optional<S, A> {
|
|
|
147
147
|
* - `replace(a, s)` should return a structurally new `S` with `a` in place
|
|
148
148
|
* of the old focus.
|
|
149
149
|
*
|
|
150
|
-
* **Example** (
|
|
150
|
+
* **Example** (Focusing on the first element of a pair)
|
|
151
151
|
*
|
|
152
152
|
* ```ts
|
|
153
153
|
* import { Optic } from "effect"
|
|
@@ -190,7 +190,7 @@ export declare function makeLens<S, A>(get: (s: S) => A, replace: (a: A, s: S) =
|
|
|
190
190
|
* - Composing two Prisms produces a Prism; composing a Prism with a
|
|
191
191
|
* {@link Lens} produces an {@link Optional}.
|
|
192
192
|
*
|
|
193
|
-
* **Example** (
|
|
193
|
+
* **Example** (Narrowing a tagged union)
|
|
194
194
|
*
|
|
195
195
|
* ```ts
|
|
196
196
|
* import { Optic, Result } from "effect"
|
|
@@ -230,7 +230,7 @@ export interface Prism<in out S, in out A> extends Optional<S, A> {
|
|
|
230
230
|
*
|
|
231
231
|
* - `getResult` should return `Result.fail(message)` on mismatch.
|
|
232
232
|
*
|
|
233
|
-
* **Example** (
|
|
233
|
+
* **Example** (Parsing a string to a number)
|
|
234
234
|
*
|
|
235
235
|
* ```ts
|
|
236
236
|
* import { Optic, Result } from "effect"
|
|
@@ -272,7 +272,7 @@ export declare function makePrism<S, A>(getResult: (s: S) => Result.Result<A, st
|
|
|
272
272
|
* any check fails.
|
|
273
273
|
* - `set` is identity — the value passes through unchanged.
|
|
274
274
|
*
|
|
275
|
-
* **Example** (positive integer prism)
|
|
275
|
+
* **Example** (Creating a positive integer prism)
|
|
276
276
|
*
|
|
277
277
|
* ```ts
|
|
278
278
|
* import { Optic, Result, Schema } from "effect"
|
|
@@ -359,7 +359,7 @@ type ForbidUnion<A, Message extends string> = IsUnion<A> extends true ? [Message
|
|
|
359
359
|
* - `modify(f)` returns the original `s` on failure (never throws).
|
|
360
360
|
* - All operations are pure; inputs are never mutated.
|
|
361
361
|
*
|
|
362
|
-
* **Example** (
|
|
362
|
+
* **Example** (Focusing on an optional record key)
|
|
363
363
|
*
|
|
364
364
|
* ```ts
|
|
365
365
|
* import { Optic, Result } from "effect"
|
|
@@ -407,7 +407,7 @@ export interface Optional<in out S, in out A> {
|
|
|
407
407
|
* Composes this optic with another. The result type is the weakest of
|
|
408
408
|
* the two: Iso + Iso = Iso, Lens + Prism = Optional, etc.
|
|
409
409
|
*
|
|
410
|
-
* **Example** (
|
|
410
|
+
* **Example** (Composing a lens with a prism)
|
|
411
411
|
*
|
|
412
412
|
* ```ts
|
|
413
413
|
* import { Optic, Option } from "effect"
|
|
@@ -428,7 +428,7 @@ export interface Optional<in out S, in out A> {
|
|
|
428
428
|
* Returns a function `(s: S) => S` that applies `f` to the focused value.
|
|
429
429
|
* If the optic cannot focus, the original `s` is returned unchanged.
|
|
430
430
|
*
|
|
431
|
-
* **Example** (
|
|
431
|
+
* **Example** (Incrementing a nested field)
|
|
432
432
|
*
|
|
433
433
|
* ```ts
|
|
434
434
|
* import { Optic } from "effect"
|
|
@@ -451,7 +451,7 @@ export interface Optional<in out S, in out A> {
|
|
|
451
451
|
* - On an {@link Optional}, returns an Optional.
|
|
452
452
|
* - Does **not** work on union types (compile error).
|
|
453
453
|
*
|
|
454
|
-
* **Example** (
|
|
454
|
+
* **Example** (Drilling into nested structs)
|
|
455
455
|
*
|
|
456
456
|
* ```ts
|
|
457
457
|
* import { Optic } from "effect"
|
|
@@ -474,7 +474,7 @@ export interface Optional<in out S, in out A> {
|
|
|
474
474
|
* - The focus type becomes `A[Key] | undefined`.
|
|
475
475
|
* - Does **not** work on union types (compile error).
|
|
476
476
|
*
|
|
477
|
-
* **Example** (
|
|
477
|
+
* **Example** (Deleting an optional key)
|
|
478
478
|
*
|
|
479
479
|
* ```ts
|
|
480
480
|
* import { Optic } from "effect"
|
|
@@ -500,7 +500,7 @@ export interface Optional<in out S, in out A> {
|
|
|
500
500
|
* - On a {@link Prism}, returns a Prism.
|
|
501
501
|
* - On an {@link Optional}, returns an Optional.
|
|
502
502
|
*
|
|
503
|
-
* **Example** (only
|
|
503
|
+
* **Example** (Focusing only on positive numbers)
|
|
504
504
|
*
|
|
505
505
|
* ```ts
|
|
506
506
|
* import { Optic, Result, Schema } from "effect"
|
|
@@ -527,7 +527,7 @@ export interface Optional<in out S, in out A> {
|
|
|
527
527
|
* - On an {@link Optional}, returns an Optional.
|
|
528
528
|
* - Pass optional `annotations` to customize the error message.
|
|
529
529
|
*
|
|
530
|
-
* **Example** (
|
|
530
|
+
* **Example** (Narrowing a union)
|
|
531
531
|
*
|
|
532
532
|
* ```ts
|
|
533
533
|
* import { Optic, Result } from "effect"
|
|
@@ -558,7 +558,7 @@ export interface Optional<in out S, in out A> {
|
|
|
558
558
|
* - On an {@link Optional}, returns an Optional.
|
|
559
559
|
* - Shorthand for `.refine(s => s._tag === tag)`.
|
|
560
560
|
*
|
|
561
|
-
* **Example** (
|
|
561
|
+
* **Example** (Focusing a tagged variant)
|
|
562
562
|
*
|
|
563
563
|
* ```ts
|
|
564
564
|
* import { Optic, Result } from "effect"
|
|
@@ -600,7 +600,7 @@ export interface Optional<in out S, in out A> {
|
|
|
600
600
|
* - Always returns an {@link Optional}.
|
|
601
601
|
* - Does **not** work on union types (compile error).
|
|
602
602
|
*
|
|
603
|
-
* **Example** (
|
|
603
|
+
* **Example** (Accessing records safely)
|
|
604
604
|
*
|
|
605
605
|
* ```ts
|
|
606
606
|
* import { Optic, Result } from "effect"
|
|
@@ -627,7 +627,7 @@ export interface Optional<in out S, in out A> {
|
|
|
627
627
|
* - On an {@link Optional}, returns an Optional.
|
|
628
628
|
* - Does **not** work on union types (compile error).
|
|
629
629
|
*
|
|
630
|
-
* **Example** (
|
|
630
|
+
* **Example** (Picking keys)
|
|
631
631
|
*
|
|
632
632
|
* ```ts
|
|
633
633
|
* import { Optic } from "effect"
|
|
@@ -653,7 +653,7 @@ export interface Optional<in out S, in out A> {
|
|
|
653
653
|
* - On an {@link Optional}, returns an Optional.
|
|
654
654
|
* - Does **not** work on union types (compile error).
|
|
655
655
|
*
|
|
656
|
-
* **Example** (
|
|
656
|
+
* **Example** (Omitting keys)
|
|
657
657
|
*
|
|
658
658
|
* ```ts
|
|
659
659
|
* import { Optic } from "effect"
|
|
@@ -676,7 +676,7 @@ export interface Optional<in out S, in out A> {
|
|
|
676
676
|
* Filters out `undefined` from the focus, producing a {@link Prism}.
|
|
677
677
|
* `getResult` fails when the focus is `undefined`.
|
|
678
678
|
*
|
|
679
|
-
* **Example** (
|
|
679
|
+
* **Example** (Filtering undefined values)
|
|
680
680
|
*
|
|
681
681
|
* ```ts
|
|
682
682
|
* import { Optic, Result } from "effect"
|
|
@@ -709,7 +709,7 @@ export interface Optional<in out S, in out A> {
|
|
|
709
709
|
* `getResult` and writes them back in order. Fails with a
|
|
710
710
|
* length-mismatch error if counts differ.
|
|
711
711
|
*
|
|
712
|
-
* **Example** (
|
|
712
|
+
* **Example** (Incrementing liked posts)
|
|
713
713
|
*
|
|
714
714
|
* ```ts
|
|
715
715
|
* import { Optic, Schema } from "effect"
|
|
@@ -747,7 +747,7 @@ export interface Optional<in out S, in out A> {
|
|
|
747
747
|
* Unlike `.modify()`, which operates on the whole array, `modifyAll`
|
|
748
748
|
* maps `f` over each individual element.
|
|
749
749
|
*
|
|
750
|
-
* **Example** (
|
|
750
|
+
* **Example** (Doubling all focused values)
|
|
751
751
|
*
|
|
752
752
|
* ```ts
|
|
753
753
|
* import { Optic, Schema } from "effect"
|
|
@@ -783,7 +783,7 @@ export interface Optional<in out S, in out A> {
|
|
|
783
783
|
* - `set` should return `Result.fail(message)` when the update cannot be
|
|
784
784
|
* applied.
|
|
785
785
|
*
|
|
786
|
-
* **Example** (
|
|
786
|
+
* **Example** (Accessing record keys safely)
|
|
787
787
|
*
|
|
788
788
|
* ```ts
|
|
789
789
|
* import { Optic, Result } from "effect"
|
|
@@ -829,7 +829,7 @@ export declare function makeOptional<S, A>(getResult: (s: S) => Result.Result<A,
|
|
|
829
829
|
* - Use `.modifyAll(f)` to map a function over every focused element.
|
|
830
830
|
* - Use {@link getAll} to extract all focused elements as a plain array.
|
|
831
831
|
*
|
|
832
|
-
* **Example** (
|
|
832
|
+
* **Example** (Traversing array elements with a filter)
|
|
833
833
|
*
|
|
834
834
|
* ```ts
|
|
835
835
|
* import { Optic, Schema } from "effect"
|
|
@@ -868,7 +868,7 @@ export interface Traversal<in out S, in out A> extends Optional<S, ReadonlyArray
|
|
|
868
868
|
* - Returns an empty array when the traversal cannot focus.
|
|
869
869
|
* - Always returns a fresh array (safe to mutate).
|
|
870
870
|
*
|
|
871
|
-
* **Example** (
|
|
871
|
+
* **Example** (Collecting positive numbers)
|
|
872
872
|
*
|
|
873
873
|
* ```ts
|
|
874
874
|
* import { Optic, Schema } from "effect"
|
|
@@ -907,7 +907,7 @@ export declare function getAll<S, A>(traversal: Traversal<S, A>): (s: S) => Arra
|
|
|
907
907
|
* - `set(a)` returns `a`.
|
|
908
908
|
* - Singleton — every call returns the same instance.
|
|
909
909
|
*
|
|
910
|
-
* **Example** (
|
|
910
|
+
* **Example** (Starting an optic chain)
|
|
911
911
|
*
|
|
912
912
|
* ```ts
|
|
913
913
|
* import { Optic } from "effect"
|
|
@@ -941,7 +941,7 @@ export declare function id<S>(): Iso<S, S>;
|
|
|
941
941
|
* - `set` uses `Object.fromEntries`.
|
|
942
942
|
* - Round-trip is lossless for `Record<string, A>`.
|
|
943
943
|
*
|
|
944
|
-
* **Example** (
|
|
944
|
+
* **Example** (Traversing record values)
|
|
945
945
|
*
|
|
946
946
|
* ```ts
|
|
947
947
|
* import { Optic, Schema } from "effect"
|
|
@@ -975,7 +975,7 @@ export declare function entries<A>(): Iso<Record<string, A>, ReadonlyArray<reado
|
|
|
975
975
|
* - `getResult` fails with an error message when the option is `None`.
|
|
976
976
|
* - `set(a)` wraps `a` in `Option.some(a)`.
|
|
977
977
|
*
|
|
978
|
-
* **Example** (
|
|
978
|
+
* **Example** (Accessing Some value)
|
|
979
979
|
*
|
|
980
980
|
* ```ts
|
|
981
981
|
* import { Optic, Option, Result } from "effect"
|
|
@@ -1012,7 +1012,7 @@ export declare function some<A>(): Prism<Option.Option<A>, A>;
|
|
|
1012
1012
|
* - `getResult` fails when the option is `Some`.
|
|
1013
1013
|
* - `set(undefined)` produces `Option.none()`.
|
|
1014
1014
|
*
|
|
1015
|
-
* **Example** (
|
|
1015
|
+
* **Example** (Matching None)
|
|
1016
1016
|
*
|
|
1017
1017
|
* ```ts
|
|
1018
1018
|
* import { Optic, Option, Result } from "effect"
|
|
@@ -1046,7 +1046,7 @@ export declare function none<A>(): Prism<Option.Option<A>, undefined>;
|
|
|
1046
1046
|
* - `getResult` fails when the result is a `Failure`.
|
|
1047
1047
|
* - `set(a)` produces `Result.succeed(a)`.
|
|
1048
1048
|
*
|
|
1049
|
-
* **Example** (
|
|
1049
|
+
* **Example** (Accessing success)
|
|
1050
1050
|
*
|
|
1051
1051
|
* ```ts
|
|
1052
1052
|
* import { Optic, Result } from "effect"
|
|
@@ -1080,7 +1080,7 @@ export declare function success<A, E>(): Prism<Result.Result<A, E>, A>;
|
|
|
1080
1080
|
* - `getResult` fails when the result is a `Success`.
|
|
1081
1081
|
* - `set(e)` produces `Result.fail(e)`.
|
|
1082
1082
|
*
|
|
1083
|
-
* **Example** (
|
|
1083
|
+
* **Example** (Accessing failure)
|
|
1084
1084
|
*
|
|
1085
1085
|
* ```ts
|
|
1086
1086
|
* import { Optic, Result } from "effect"
|
package/dist/Optic.js
CHANGED
|
@@ -30,7 +30,7 @@ import * as Struct from "./Struct.js";
|
|
|
30
30
|
*
|
|
31
31
|
* The returned optic can be composed with any other optic.
|
|
32
32
|
*
|
|
33
|
-
* **Example** (
|
|
33
|
+
* **Example** (Wrapping and unwrapping a branded type)
|
|
34
34
|
*
|
|
35
35
|
* ```ts
|
|
36
36
|
* import { Optic } from "effect"
|
|
@@ -70,7 +70,7 @@ export function makeIso(get, set) {
|
|
|
70
70
|
* - `replace(a, s)` should return a structurally new `S` with `a` in place
|
|
71
71
|
* of the old focus.
|
|
72
72
|
*
|
|
73
|
-
* **Example** (
|
|
73
|
+
* **Example** (Focusing on the first element of a pair)
|
|
74
74
|
*
|
|
75
75
|
* ```ts
|
|
76
76
|
* import { Optic } from "effect"
|
|
@@ -108,7 +108,7 @@ export function makeLens(get, replace) {
|
|
|
108
108
|
*
|
|
109
109
|
* - `getResult` should return `Result.fail(message)` on mismatch.
|
|
110
110
|
*
|
|
111
|
-
* **Example** (
|
|
111
|
+
* **Example** (Parsing a string to a number)
|
|
112
112
|
*
|
|
113
113
|
* ```ts
|
|
114
114
|
* import { Optic, Result } from "effect"
|
|
@@ -152,7 +152,7 @@ export function makePrism(getResult, set) {
|
|
|
152
152
|
* any check fails.
|
|
153
153
|
* - `set` is identity — the value passes through unchanged.
|
|
154
154
|
*
|
|
155
|
-
* **Example** (positive integer prism)
|
|
155
|
+
* **Example** (Creating a positive integer prism)
|
|
156
156
|
*
|
|
157
157
|
* ```ts
|
|
158
158
|
* import { Optic, Result, Schema } from "effect"
|
|
@@ -294,7 +294,7 @@ function compose(a, b) {
|
|
|
294
294
|
* - `set` should return `Result.fail(message)` when the update cannot be
|
|
295
295
|
* applied.
|
|
296
296
|
*
|
|
297
|
-
* **Example** (
|
|
297
|
+
* **Example** (Accessing record keys safely)
|
|
298
298
|
*
|
|
299
299
|
* ```ts
|
|
300
300
|
* import { Optic, Result } from "effect"
|
|
@@ -649,7 +649,7 @@ function getCompositionTag(a, b) {
|
|
|
649
649
|
* - Returns an empty array when the traversal cannot focus.
|
|
650
650
|
* - Always returns a fresh array (safe to mutate).
|
|
651
651
|
*
|
|
652
|
-
* **Example** (
|
|
652
|
+
* **Example** (Collecting positive numbers)
|
|
653
653
|
*
|
|
654
654
|
* ```ts
|
|
655
655
|
* import { Optic, Schema } from "effect"
|
|
@@ -697,7 +697,7 @@ const identityIso = /*#__PURE__*/make(identityNode);
|
|
|
697
697
|
* - `set(a)` returns `a`.
|
|
698
698
|
* - Singleton — every call returns the same instance.
|
|
699
699
|
*
|
|
700
|
-
* **Example** (
|
|
700
|
+
* **Example** (Starting an optic chain)
|
|
701
701
|
*
|
|
702
702
|
* ```ts
|
|
703
703
|
* import { Optic } from "effect"
|
|
@@ -733,7 +733,7 @@ export function id() {
|
|
|
733
733
|
* - `set` uses `Object.fromEntries`.
|
|
734
734
|
* - Round-trip is lossless for `Record<string, A>`.
|
|
735
735
|
*
|
|
736
|
-
* **Example** (
|
|
736
|
+
* **Example** (Traversing record values)
|
|
737
737
|
*
|
|
738
738
|
* ```ts
|
|
739
739
|
* import { Optic, Schema } from "effect"
|
|
@@ -769,7 +769,7 @@ export function entries() {
|
|
|
769
769
|
* - `getResult` fails with an error message when the option is `None`.
|
|
770
770
|
* - `set(a)` wraps `a` in `Option.some(a)`.
|
|
771
771
|
*
|
|
772
|
-
* **Example** (
|
|
772
|
+
* **Example** (Accessing Some value)
|
|
773
773
|
*
|
|
774
774
|
* ```ts
|
|
775
775
|
* import { Optic, Option, Result } from "effect"
|
|
@@ -814,7 +814,7 @@ export function some() {
|
|
|
814
814
|
* - `getResult` fails when the option is `Some`.
|
|
815
815
|
* - `set(undefined)` produces `Option.none()`.
|
|
816
816
|
*
|
|
817
|
-
* **Example** (
|
|
817
|
+
* **Example** (Matching None)
|
|
818
818
|
*
|
|
819
819
|
* ```ts
|
|
820
820
|
* import { Optic, Option, Result } from "effect"
|
|
@@ -856,7 +856,7 @@ export function none() {
|
|
|
856
856
|
* - `getResult` fails when the result is a `Failure`.
|
|
857
857
|
* - `set(a)` produces `Result.succeed(a)`.
|
|
858
858
|
*
|
|
859
|
-
* **Example** (
|
|
859
|
+
* **Example** (Accessing success)
|
|
860
860
|
*
|
|
861
861
|
* ```ts
|
|
862
862
|
* import { Optic, Result } from "effect"
|
|
@@ -898,7 +898,7 @@ export function success() {
|
|
|
898
898
|
* - `getResult` fails when the result is a `Success`.
|
|
899
899
|
* - `set(e)` produces `Result.fail(e)`.
|
|
900
900
|
*
|
|
901
|
-
* **Example** (
|
|
901
|
+
* **Example** (Accessing failure)
|
|
902
902
|
*
|
|
903
903
|
* ```ts
|
|
904
904
|
* import { Optic, Result } from "effect"
|
package/dist/Option.d.ts
CHANGED
|
@@ -1049,7 +1049,7 @@ export declare const firstSomeOf: <T, C extends Iterable<Option<T>> = Iterable<O
|
|
|
1049
1049
|
* - `null` or `undefined` → `None`
|
|
1050
1050
|
* - Any other value → `Some` (typed as `NonNullable<A>`)
|
|
1051
1051
|
*
|
|
1052
|
-
* **Example** (
|
|
1052
|
+
* **Example** (Converting nullable values to an Option)
|
|
1053
1053
|
*
|
|
1054
1054
|
* ```ts
|
|
1055
1055
|
* import { Option } from "effect"
|
|
@@ -1086,7 +1086,7 @@ export declare const fromNullishOr: <A>(a: A) => Option<NonNullable<A>>;
|
|
|
1086
1086
|
* - `undefined` → `None`
|
|
1087
1087
|
* - Any other value (including `null`) → `Some`
|
|
1088
1088
|
*
|
|
1089
|
-
* **Example** (
|
|
1089
|
+
* **Example** (Converting possibly undefined values to an Option)
|
|
1090
1090
|
*
|
|
1091
1091
|
* ```ts
|
|
1092
1092
|
* import { Option } from "effect"
|
|
@@ -1122,7 +1122,7 @@ export declare const fromUndefinedOr: <A>(a: A) => Option<Exclude<A, undefined>>
|
|
|
1122
1122
|
* - `null` → `None`
|
|
1123
1123
|
* - Any other value (including `undefined`) → `Some`
|
|
1124
1124
|
*
|
|
1125
|
-
* **Example** (
|
|
1125
|
+
* **Example** (Converting possibly null values to an Option)
|
|
1126
1126
|
*
|
|
1127
1127
|
* ```ts
|
|
1128
1128
|
* import { Option } from "effect"
|
|
@@ -1625,7 +1625,7 @@ export {
|
|
|
1625
1625
|
*
|
|
1626
1626
|
* Use to return a "success with no meaningful value" from an `Option`-returning function
|
|
1627
1627
|
*
|
|
1628
|
-
* **Example** (
|
|
1628
|
+
* **Example** (Referencing Option.void)
|
|
1629
1629
|
*
|
|
1630
1630
|
* ```ts
|
|
1631
1631
|
* import { Option } from "effect"
|
|
@@ -3769,7 +3769,7 @@ export declare const liftPredicate: {
|
|
|
3769
3769
|
* - `Some` where `isEquivalent(value, a)` is `true` → `true`
|
|
3770
3770
|
* - `Some` where not equivalent, or `None` → `false`
|
|
3771
3771
|
*
|
|
3772
|
-
* **Example** (
|
|
3772
|
+
* **Example** (Checking with custom equivalence)
|
|
3773
3773
|
*
|
|
3774
3774
|
* ```ts
|
|
3775
3775
|
* import { Equivalence, Option } from "effect"
|
|
@@ -4346,7 +4346,7 @@ export declare const bind: {
|
|
|
4346
4346
|
* Use when you need to start an `Option` do notation pipeline before adding
|
|
4347
4347
|
* bindings.
|
|
4348
4348
|
*
|
|
4349
|
-
* **Example** (
|
|
4349
|
+
* **Example** (Building Option pipelines with do notation)
|
|
4350
4350
|
*
|
|
4351
4351
|
* ```ts
|
|
4352
4352
|
* import { Option, pipe } from "effect"
|
|
@@ -4385,7 +4385,7 @@ export declare const Do: Option<{}>;
|
|
|
4385
4385
|
* - The return value is wrapped in `Some`
|
|
4386
4386
|
* - No `Effect` runtime is needed
|
|
4387
4387
|
*
|
|
4388
|
-
* **Example** (
|
|
4388
|
+
* **Example** (Sequencing Option computations with generator syntax)
|
|
4389
4389
|
*
|
|
4390
4390
|
* ```ts
|
|
4391
4391
|
* import { Option } from "effect"
|
package/dist/Option.js
CHANGED
|
@@ -538,7 +538,7 @@ export const firstSomeOf = collection => {
|
|
|
538
538
|
* - `null` or `undefined` → `None`
|
|
539
539
|
* - Any other value → `Some` (typed as `NonNullable<A>`)
|
|
540
540
|
*
|
|
541
|
-
* **Example** (
|
|
541
|
+
* **Example** (Converting nullable values to an Option)
|
|
542
542
|
*
|
|
543
543
|
* ```ts
|
|
544
544
|
* import { Option } from "effect"
|
|
@@ -575,7 +575,7 @@ export const fromNullishOr = a => a == null ? none() : some(a);
|
|
|
575
575
|
* - `undefined` → `None`
|
|
576
576
|
* - Any other value (including `null`) → `Some`
|
|
577
577
|
*
|
|
578
|
-
* **Example** (
|
|
578
|
+
* **Example** (Converting possibly undefined values to an Option)
|
|
579
579
|
*
|
|
580
580
|
* ```ts
|
|
581
581
|
* import { Option } from "effect"
|
|
@@ -611,7 +611,7 @@ export const fromUndefinedOr = a => a === undefined ? none() : some(a);
|
|
|
611
611
|
* - `null` → `None`
|
|
612
612
|
* - Any other value (including `undefined`) → `Some`
|
|
613
613
|
*
|
|
614
|
-
* **Example** (
|
|
614
|
+
* **Example** (Converting possibly null values to an Option)
|
|
615
615
|
*
|
|
616
616
|
* ```ts
|
|
617
617
|
* import { Option } from "effect"
|
|
@@ -938,7 +938,7 @@ export {
|
|
|
938
938
|
*
|
|
939
939
|
* Use to return a "success with no meaningful value" from an `Option`-returning function
|
|
940
940
|
*
|
|
941
|
-
* **Example** (
|
|
941
|
+
* **Example** (Referencing Option.void)
|
|
942
942
|
*
|
|
943
943
|
* ```ts
|
|
944
944
|
* import { Option } from "effect"
|
|
@@ -1787,7 +1787,7 @@ export const liftPredicate = /*#__PURE__*/dual(2, (b, predicate) => predicate(b)
|
|
|
1787
1787
|
* - `Some` where `isEquivalent(value, a)` is `true` → `true`
|
|
1788
1788
|
* - `Some` where not equivalent, or `None` → `false`
|
|
1789
1789
|
*
|
|
1790
|
-
* **Example** (
|
|
1790
|
+
* **Example** (Checking with custom equivalence)
|
|
1791
1791
|
*
|
|
1792
1792
|
* ```ts
|
|
1793
1793
|
* import { Equivalence, Option } from "effect"
|
|
@@ -1993,7 +1993,7 @@ export const bind = /*#__PURE__*/doNotation.bind(map, flatMap);
|
|
|
1993
1993
|
* Use when you need to start an `Option` do notation pipeline before adding
|
|
1994
1994
|
* bindings.
|
|
1995
1995
|
*
|
|
1996
|
-
* **Example** (
|
|
1996
|
+
* **Example** (Building Option pipelines with do notation)
|
|
1997
1997
|
*
|
|
1998
1998
|
* ```ts
|
|
1999
1999
|
* import { Option, pipe } from "effect"
|
|
@@ -2032,7 +2032,7 @@ export const Do = /*#__PURE__*/some({});
|
|
|
2032
2032
|
* - The return value is wrapped in `Some`
|
|
2033
2033
|
* - No `Effect` runtime is needed
|
|
2034
2034
|
*
|
|
2035
|
-
* **Example** (
|
|
2035
|
+
* **Example** (Sequencing Option computations with generator syntax)
|
|
2036
2036
|
*
|
|
2037
2037
|
* ```ts
|
|
2038
2038
|
* import { Option } from "effect"
|