effect-lens 0.1.5 → 0.2.1
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/README.md +55 -11
- package/dist/Lens.d.ts +282 -38
- package/dist/Lens.js +297 -55
- package/dist/Lens.js.map +1 -1
- package/dist/Subscribable.d.ts +70 -7
- package/dist/Subscribable.js +64 -1
- package/dist/Subscribable.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
A Lens type for [Effect](https://effect.website/) to easily manage nested state.
|
|
4
4
|
|
|
5
|
+
This version is for Effect v3. For Effect v4, use version 2.X.X-beta.X.
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
```
|
|
7
9
|
npm install effect-lens
|
|
@@ -28,7 +30,7 @@ Lens<
|
|
|
28
30
|
A, // Type of the value the lens is focused on
|
|
29
31
|
ER, // Errors that can happen when reading
|
|
30
32
|
EW, // Errors that can happen when writing
|
|
31
|
-
|
|
33
|
+
RR, // Requirements for reading
|
|
32
34
|
RW // Requirements for writing
|
|
33
35
|
>
|
|
34
36
|
```
|
|
@@ -55,11 +57,14 @@ yield* Lens.update(lens, Array.replace(1, 1664))
|
|
|
55
57
|
Currently available:
|
|
56
58
|
- `fromSubscriptionRef`
|
|
57
59
|
- `fromSynchronizedRef` (note: since `SynchronizedRef` is not reactive (does not produce a stream of value changes), the resulting Lens' `changes` stream will only emit the current value of the lens when evaluated, and nothing else)
|
|
58
|
-
|
|
59
|
-
More to come!
|
|
60
|
+
- `fromRef` (returns an effect because it creates an internal lock)
|
|
60
61
|
|
|
61
62
|
#### Manually
|
|
62
|
-
You can also create Lenses manually using `make` by providing
|
|
63
|
+
You can also create Lenses manually using `make` by providing:
|
|
64
|
+
- `get`: an effect that reads the current value,
|
|
65
|
+
- `changes`: a stream of value changes,
|
|
66
|
+
- `commit`: an effectful write primitive,
|
|
67
|
+
- `lock`: an effect that produces the lock used to serialize writes.
|
|
63
68
|
|
|
64
69
|
You can get pretty creative! Here's an example of a Lens that points to a specific key of the browser `LocalStorage`:
|
|
65
70
|
```typescript
|
|
@@ -67,8 +72,9 @@ You can get pretty creative! Here's an example of a Lens that points to a specif
|
|
|
67
72
|
const lens = Effect.all([
|
|
68
73
|
KeyValueStore.KeyValueStore,
|
|
69
74
|
Effect.succeed("someKey"),
|
|
75
|
+
Effect.makeSemaphore(1),
|
|
70
76
|
]).pipe(
|
|
71
|
-
Effect.map(([kv, key]) => Lens.make({
|
|
77
|
+
Effect.map(([kv, key, semaphore]) => Lens.make({
|
|
72
78
|
get: kv.get(key),
|
|
73
79
|
|
|
74
80
|
changes: kv.get(key).pipe(
|
|
@@ -83,9 +89,11 @@ const lens = Effect.all([
|
|
|
83
89
|
Stream.unwrap,
|
|
84
90
|
),
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
commit: a => Option.isSome(a)
|
|
87
93
|
? kv.set(key, a.value)
|
|
88
94
|
: kv.remove(key),
|
|
95
|
+
|
|
96
|
+
lock: Effect.succeed(semaphore.withPermits(1)),
|
|
89
97
|
})),
|
|
90
98
|
|
|
91
99
|
Effect.provide(BrowserKeyValueStore.layerLocalStorage),
|
|
@@ -165,8 +173,7 @@ Currently available:
|
|
|
165
173
|
| `focusTupleAt` | Focuses to an indexed entry of a readonly tuple. Replaces the parent tuple immutably when writing to the focused index | Immutable | |
|
|
166
174
|
| `focusMutableTupleAt` | Focuses to an indexed entry of a mutable tuple. Mutates the parent tuple in place at the focused index | Mutable | Type-safe: will not allow you to mutate `readonly` tuples |
|
|
167
175
|
| `focusChunkAt` | Focuses to an indexed entry of a `Chunk`. Replaces the parent `Chunk` immutably when writing to the focused element | Immutable | |
|
|
168
|
-
|
|
169
|
-
Also more to come!
|
|
176
|
+
| `focusOption` | Focuses to the value inside an `Option`. Wraps writes back into `Option.some` | Immutable | Reading or writing fails with `NoSuchElementException` when the parent option is `None` |
|
|
170
177
|
|
|
171
178
|
#### Manually
|
|
172
179
|
You can create focused Lenses by composing them manually using `map`, `mapEffect` and `unwrap`:
|
|
@@ -196,6 +203,42 @@ const benzemonstreLens = ref.pipe(
|
|
|
196
203
|
// As you can see, this is automatically tracked by the Lens type
|
|
197
204
|
```
|
|
198
205
|
|
|
206
|
+
#### Low-level derived lenses
|
|
207
|
+
For advanced cases, you can derive a Lens manually using `derive`. This is the primitive used by the built-in transforms.
|
|
208
|
+
|
|
209
|
+
A derived Lens describes how to transform three parent channels:
|
|
210
|
+
- `resolve`: reads the parent and returns the focused value plus a `commit` function to rebuild the parent,
|
|
211
|
+
- `mapStream`: transforms the parent `changes` stream,
|
|
212
|
+
- `mapLock`: transforms the parent write lock.
|
|
213
|
+
|
|
214
|
+
Most custom focusing logic should use `map` or `mapEffect`, but `derive` is useful when you need full control over read, stream, lock, and write-back behavior.
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
declare const lens: Lens.Lens<User, never, never, never, never>
|
|
218
|
+
|
|
219
|
+
const nameLens = lens.pipe(
|
|
220
|
+
Lens.derive({
|
|
221
|
+
resolve: parent => Effect.map(
|
|
222
|
+
parent,
|
|
223
|
+
resolved => ({
|
|
224
|
+
value: resolved.value.name,
|
|
225
|
+
commit: next => resolved.commit(
|
|
226
|
+
Effect.map(next, name => ({
|
|
227
|
+
...resolved.value,
|
|
228
|
+
name,
|
|
229
|
+
})),
|
|
230
|
+
),
|
|
231
|
+
}),
|
|
232
|
+
),
|
|
233
|
+
|
|
234
|
+
mapStream: Stream.map(user => user.name),
|
|
235
|
+
|
|
236
|
+
// This derived Lens does not add lock behavior, so it reuses the parent lock.
|
|
237
|
+
mapLock: identity,
|
|
238
|
+
}),
|
|
239
|
+
)
|
|
240
|
+
```
|
|
241
|
+
|
|
199
242
|
|
|
200
243
|
### Subscribable
|
|
201
244
|
|
|
@@ -222,7 +265,7 @@ yield* someFunctionThatShouldOnlyHaveReadonlyAccessToTheState(lens)
|
|
|
222
265
|
```
|
|
223
266
|
|
|
224
267
|
#### Focusing
|
|
225
|
-
This library re-exports Effect's `Subscribable` module and adds
|
|
268
|
+
This library re-exports Effect's `Subscribable` module and adds error transforms and recovery (`catchAll`, `catchAllCause`, `orElse`, `orElseSucceed`, and `retry`), plus transforms to narrow the focus of `Subscribable`'s, same as Lenses:
|
|
226
269
|
```typescript
|
|
227
270
|
import { Subscribable } from "effect-lens"
|
|
228
271
|
|
|
@@ -240,15 +283,16 @@ Currently available:
|
|
|
240
283
|
| - | - |
|
|
241
284
|
| `focusObjectOn` | Focuses to the field of an object |
|
|
242
285
|
| `focusArrayAt` | Focuses to an indexed entry of an array |
|
|
286
|
+
| `focusArrayLength` | Focuses to the length of an array |
|
|
243
287
|
| `focusTupleAt` | Focuses to an indexed entry of a tuple |
|
|
244
288
|
| `focusChunkAt` | Focuses to an indexed entry of a `Chunk` |
|
|
289
|
+
| `focusChunkSize` | Focuses to the size of a `Chunk` |
|
|
290
|
+
| `focusIterableSize` | Focuses to the size of an iterable |
|
|
245
291
|
|
|
246
292
|
|
|
247
293
|
## Todo
|
|
248
294
|
|
|
249
295
|
This library is already ready to use! However, there is always more to do...
|
|
250
|
-
- Finish those docs
|
|
251
296
|
- Provide an API reference
|
|
252
297
|
- Add new adapters for various data source types
|
|
253
298
|
- Add new focus transforms
|
|
254
|
-
- Provide a preview version for Effect 4 beta
|
package/dist/Lens.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chunk, Effect, Option, Pipeable, Readable, Stream, type SubscriptionRef, type SynchronizedRef } from "effect";
|
|
1
|
+
import { Chunk, type Context, Effect, Option, Pipeable, PubSub, Readable, Ref, Stream, type SubscriptionRef, type SynchronizedRef } from "effect";
|
|
2
2
|
import type { NoSuchElementException } from "effect/Cause";
|
|
3
3
|
import * as Subscribable from "./Subscribable.js";
|
|
4
4
|
export declare const LensTypeId: unique symbol;
|
|
@@ -12,42 +12,96 @@ export type LensTypeId = typeof LensTypeId;
|
|
|
12
12
|
*/
|
|
13
13
|
export interface Lens<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never> extends Subscribable.Subscribable<A, ER, RR> {
|
|
14
14
|
readonly [LensTypeId]: LensTypeId;
|
|
15
|
-
readonly
|
|
15
|
+
readonly modifyEffect: <B, E1 = never, R1 = never>(f: (a: A) => Effect.Effect<readonly [B, A], E1, R1>) => Effect.Effect<B, ER | EW | E1, RR | RW | R1>;
|
|
16
16
|
}
|
|
17
|
-
declare const LensImpl_base: Pipeable.PipeableConstructor;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* Checks whether a value is a `Lens`.
|
|
20
19
|
*/
|
|
21
|
-
export declare
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
export declare const isLens: (u: unknown) => u is Lens<unknown, unknown, unknown, unknown, unknown>;
|
|
21
|
+
export declare const LensImplTypeId: unique symbol;
|
|
22
|
+
export type LensImplTypeId = typeof LensImplTypeId;
|
|
23
|
+
export declare namespace LensImpl {
|
|
24
|
+
interface Resolved<in out A, in out EW = never, in out RW = never> {
|
|
25
|
+
readonly value: A;
|
|
26
|
+
readonly commit: <E = never, R = never>(next: Effect.Effect<A, E, R>) => Effect.Effect<void, EW | E, RW | R>;
|
|
27
|
+
}
|
|
28
|
+
interface Lock {
|
|
29
|
+
<A1, E1, R1>(self: Effect.Effect<A1, E1, R1>): Effect.Effect<A1, E1, R1>;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
declare const LensImpl_base: Pipeable.PipeableConstructor;
|
|
33
|
+
export declare abstract class LensImpl<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never> extends LensImpl_base implements Lens<A, ER, EW, RR, RW> {
|
|
25
34
|
readonly [Readable.TypeId]: Readable.TypeId;
|
|
26
35
|
readonly [Subscribable.TypeId]: Subscribable.TypeId;
|
|
27
36
|
readonly [LensTypeId]: LensTypeId;
|
|
28
|
-
|
|
37
|
+
readonly [LensImplTypeId]: LensImplTypeId;
|
|
38
|
+
abstract readonly resolve: Effect.Effect<LensImpl.Resolved<A, EW, RW>, ER, RR>;
|
|
39
|
+
abstract readonly changes: Stream.Stream<A, ER, RR>;
|
|
40
|
+
abstract readonly lock: Effect.Effect<LensImpl.Lock, EW, RW>;
|
|
41
|
+
get get(): Effect.Effect<A, ER, RR>;
|
|
42
|
+
modifyEffect<B, E1 = never, R1 = never>(f: (a: A) => Effect.Effect<readonly [B, A], E1, R1>): Effect.Effect<B, ER | EW | E1, RR | RW | R1>;
|
|
43
|
+
}
|
|
44
|
+
export declare const isLensImpl: (u: unknown) => u is LensImpl<unknown, unknown, unknown, unknown, unknown>;
|
|
45
|
+
export declare const asLensImpl: <A, ER, EW, RR, RW>(lens: Lens<A, ER, EW, RR, RW>) => LensImpl<A, ER, EW, RR, RW>;
|
|
46
|
+
export declare const asSubscribable: <A, ER, EW, RR, RW>(lens: Lens<A, ER, EW, RR, RW>) => Subscribable.Subscribable<A, ER, RR>;
|
|
47
|
+
export declare namespace LensLazyImpl {
|
|
48
|
+
interface Source<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never> {
|
|
49
|
+
readonly get: Effect.Effect<A, ER, RR>;
|
|
50
|
+
readonly changes: Stream.Stream<A, ER, RR>;
|
|
51
|
+
readonly commit: (a: A) => Effect.Effect<void, EW, RW>;
|
|
52
|
+
readonly lock: Effect.Effect<LensImpl.Lock, EW, RW>;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare class LensLazyImpl<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never> extends LensImpl<A, ER, EW, RR, RW> {
|
|
56
|
+
readonly source: LensLazyImpl.Source<A, ER, EW, RR, RW>;
|
|
57
|
+
constructor(source: LensLazyImpl.Source<A, ER, EW, RR, RW>);
|
|
58
|
+
get resolve(): Effect.Effect<LensImpl.Resolved<A, EW, RW>, ER, RR>;
|
|
59
|
+
get changes(): Stream.Stream<A, ER, RR>;
|
|
60
|
+
get lock(): Effect.Effect<LensImpl.Lock, EW, RW>;
|
|
29
61
|
}
|
|
30
62
|
/**
|
|
31
|
-
*
|
|
63
|
+
* Creates a `Lens` by supplying how to read the current value, observe changes, and apply transformations.
|
|
32
64
|
*/
|
|
33
|
-
export declare const
|
|
65
|
+
export declare const make: <A, ER, EW, RR, RW>(source: LensLazyImpl.Source<A, ER, EW, RR, RW>) => Lens<A, ER, EW, RR, RW>;
|
|
66
|
+
export declare class UnwrappedLensImpl<in out A, in out ER, in out EW, in out RR, in out RW, in out E1, in out R1> extends LensImpl<A, ER | E1, EW | E1, RR | R1, RW | R1> {
|
|
67
|
+
readonly effect: Effect.Effect<Lens<A, ER, EW, RR, RW>, E1, R1>;
|
|
68
|
+
constructor(effect: Effect.Effect<Lens<A, ER, EW, RR, RW>, E1, R1>);
|
|
69
|
+
get resolve(): Effect.Effect<LensImpl.Resolved<A, EW | E1, RW | R1>, ER | E1, RR | R1>;
|
|
70
|
+
get changes(): Stream.Stream<A, ER | E1, RR | R1>;
|
|
71
|
+
get lock(): Effect.Effect<LensImpl.Lock, EW | E1, RW | R1>;
|
|
72
|
+
}
|
|
34
73
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* Either `modify` or `set` needs to be supplied.
|
|
74
|
+
* Flattens an effectful `Lens`.
|
|
38
75
|
*/
|
|
39
|
-
export declare const
|
|
40
|
-
|
|
41
|
-
readonly
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
76
|
+
export declare const unwrap: <A, ER, EW, RR, RW, E1, R1>(effect: Effect.Effect<Lens<A, ER, EW, RR, RW>, E1, R1>) => Lens<A, ER | E1, EW | E1, RR | R1, RW | R1>;
|
|
77
|
+
export declare class RefLensImpl<in out A> extends LensImpl<A, never, never, never, never> {
|
|
78
|
+
readonly ref: Ref.Ref<A>;
|
|
79
|
+
readonly semaphore: Effect.Semaphore;
|
|
80
|
+
constructor(ref: Ref.Ref<A>, semaphore: Effect.Semaphore);
|
|
81
|
+
get resolve(): Effect.Effect<LensImpl.Resolved<A>, never, never>;
|
|
82
|
+
get changes(): Stream.Stream<A, never, never>;
|
|
83
|
+
get lock(): Effect.Effect<(<A_1, E, R>(self: Effect.Effect<A_1, E, R>) => Effect.Effect<A_1, E, R>), never, never>;
|
|
84
|
+
}
|
|
47
85
|
/**
|
|
48
|
-
* Creates a `Lens` that proxies a `
|
|
86
|
+
* Creates a `Lens` that proxies a `Ref`.
|
|
87
|
+
*
|
|
88
|
+
* Note: since `Ref` does not provide any kind of reactivity mechanism, the produced `Lens` will be non-reactive.
|
|
89
|
+
* This means its `changes` stream will only emit the current value once when evaluated and nothing else.
|
|
49
90
|
*/
|
|
50
|
-
export declare const
|
|
91
|
+
export declare const fromRef: <A>(ref: Ref.Ref<A>) => Effect.Effect<Lens<A, never, never, never, never>, never, never>;
|
|
92
|
+
export declare namespace SynchronizedRefLensImpl {
|
|
93
|
+
interface SynchronizedRefWithInternals<in out A> extends SynchronizedRef.SynchronizedRef<A> {
|
|
94
|
+
readonly ref: Ref.Ref<A>;
|
|
95
|
+
readonly withLock: LensImpl.Lock;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export declare class SynchronizedRefLensImpl<in out A> extends LensImpl<A, never, never, never, never> {
|
|
99
|
+
readonly ref: SynchronizedRefLensImpl.SynchronizedRefWithInternals<A>;
|
|
100
|
+
constructor(ref: SynchronizedRefLensImpl.SynchronizedRefWithInternals<A>);
|
|
101
|
+
get resolve(): Effect.Effect<LensImpl.Resolved<A>, never, never>;
|
|
102
|
+
get changes(): Stream.Stream<A, never, never>;
|
|
103
|
+
get lock(): Effect.Effect<LensImpl.Lock, never, never>;
|
|
104
|
+
}
|
|
51
105
|
/**
|
|
52
106
|
* Creates a `Lens` that proxies a `SynchronizedRef`.
|
|
53
107
|
*
|
|
@@ -55,23 +109,59 @@ export declare const fromSubscriptionRef: <A>(ref: SubscriptionRef.SubscriptionR
|
|
|
55
109
|
* This means its `changes` stream will only emit the current value once when evaluated and nothing else.
|
|
56
110
|
*/
|
|
57
111
|
export declare const fromSynchronizedRef: <A>(ref: SynchronizedRef.SynchronizedRef<A>) => Lens<A, never, never, never, never>;
|
|
112
|
+
export declare namespace SubscriptionRefLensImpl {
|
|
113
|
+
interface SubscriptionRefWithInternals<in out A> extends SubscriptionRef.SubscriptionRef<A> {
|
|
114
|
+
readonly ref: Ref.Ref<A>;
|
|
115
|
+
readonly pubsub: PubSub.PubSub<A>;
|
|
116
|
+
readonly semaphore: Effect.Semaphore;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export declare class SubscriptionRefLensImpl<in out A> extends LensImpl<A, never, never, never, never> {
|
|
120
|
+
readonly ref: SubscriptionRefLensImpl.SubscriptionRefWithInternals<A>;
|
|
121
|
+
constructor(ref: SubscriptionRefLensImpl.SubscriptionRefWithInternals<A>);
|
|
122
|
+
get resolve(): Effect.Effect<LensImpl.Resolved<A>, never, never>;
|
|
123
|
+
get changes(): Stream.Stream<A, never, never>;
|
|
124
|
+
get lock(): Effect.Effect<(<A_1, E, R>(self: Effect.Effect<A_1, E, R>) => Effect.Effect<A_1, E, R>), never, never>;
|
|
125
|
+
}
|
|
58
126
|
/**
|
|
59
|
-
*
|
|
127
|
+
* Creates a `Lens` that proxies a `SubscriptionRef`.
|
|
60
128
|
*/
|
|
61
|
-
export declare const
|
|
129
|
+
export declare const fromSubscriptionRef: <A>(ref: SubscriptionRef.SubscriptionRef<A>) => Lens<A, never, never, never, never>;
|
|
130
|
+
export declare namespace DerivedLensImpl {
|
|
131
|
+
interface Source<in out A, in out B, in out ER = never, in out ESR = never, in out EW = never, in out ESW = never, in out RR = never, in out RSR = never, in out RW = never, in out RSW = never> {
|
|
132
|
+
readonly resolve: (effect: Effect.Effect<LensImpl.Resolved<B, ESW, RSW>, ESR, RSR>) => Effect.Effect<LensImpl.Resolved<A, EW, RW>, ER, RR>;
|
|
133
|
+
readonly mapStream: (stream: Stream.Stream<B, ESR, RSR>) => Stream.Stream<A, ER, RR>;
|
|
134
|
+
readonly mapLock: (lock: Effect.Effect<LensImpl.Lock, ESW, RSW>) => Effect.Effect<LensImpl.Lock, EW, RW>;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export declare class DerivedLensImpl<in out A, in out B, in out ER = never, in out PER = never, in out EW = never, in out PEW = never, in out RR = never, in out PRR = never, in out RW = never, in out PRW = never> extends LensImpl<A, ER, EW, RR, RW> {
|
|
138
|
+
readonly parent: LensImpl<B, PER, PEW, PRR, PRW>;
|
|
139
|
+
readonly source: DerivedLensImpl.Source<A, B, ER, PER, EW, PEW, RR, PRR, RW, PRW>;
|
|
140
|
+
constructor(parent: LensImpl<B, PER, PEW, PRR, PRW>, source: DerivedLensImpl.Source<A, B, ER, PER, EW, PEW, RR, PRR, RW, PRW>);
|
|
141
|
+
get resolve(): Effect.Effect<LensImpl.Resolved<A, EW, RW>, ER, RR>;
|
|
142
|
+
get changes(): Stream.Stream<A, ER, RR>;
|
|
143
|
+
get lock(): Effect.Effect<LensImpl.Lock, EW, RW>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Derives a new `Lens` by linking a step to an existing parent lens.
|
|
147
|
+
*/
|
|
148
|
+
export declare const derive: {
|
|
149
|
+
<A, B, ER, EW, RR, RW, ER2, EW2, RR2, RW2>(source: DerivedLensImpl.Source<A, B, ER2, ER, EW2, EW, RR2, RR, RW2, RW>): (self: Lens<B, ER, EW, RR, RW>) => Lens<A, ER2, EW2, RR2, RW2>;
|
|
150
|
+
<A, B, ER, EW, RR, RW, ER2, EW2, RR2, RW2>(self: Lens<B, ER, EW, RR, RW>, source: DerivedLensImpl.Source<A, B, ER2, ER, EW2, EW, RR2, RR, RW2, RW>): Lens<A, ER2, EW2, RR2, RW2>;
|
|
151
|
+
};
|
|
62
152
|
/**
|
|
63
153
|
* Derives a new `Lens` by applying synchronous getters and setters over the focused value.
|
|
64
154
|
*/
|
|
65
155
|
export declare const map: {
|
|
66
|
-
<A, ER, EW, RR, RW, B>(self: Lens<A, ER, EW, RR, RW>, get: (a: NoInfer<A>) => B, set: (a: NoInfer<A>, b: B) => NoInfer<A>): Lens<B, ER, EW, RR, RW>;
|
|
67
156
|
<A, ER, EW, RR, RW, B>(get: (a: NoInfer<A>) => B, set: (a: NoInfer<A>, b: B) => NoInfer<A>): (self: Lens<A, ER, EW, RR, RW>) => Lens<B, ER, EW, RR, RW>;
|
|
157
|
+
<A, ER, EW, RR, RW, B>(self: Lens<A, ER, EW, RR, RW>, get: (a: NoInfer<A>) => B, set: (a: NoInfer<A>, b: B) => NoInfer<A>): Lens<B, ER, EW, RR, RW>;
|
|
68
158
|
};
|
|
69
159
|
/**
|
|
70
160
|
* Derives a new `Lens` by applying effectful getters and setters over the focused value.
|
|
71
161
|
*/
|
|
72
162
|
export declare const mapEffect: {
|
|
73
|
-
<A, ER, EW, RR, RW, B, EGet = never, RGet = never, ESet = never, RSet = never>(self: Lens<A, ER, EW, RR, RW>, get: (a: NoInfer<A>) => Effect.Effect<B, EGet, RGet>, set: (a: NoInfer<A>, b: B) => Effect.Effect<NoInfer<A>, ESet, RSet>): Lens<B, ER | EGet, EW | ESet, RR | RGet, RW | RSet>;
|
|
74
163
|
<A, ER, EW, RR, RW, B, EGet = never, RGet = never, ESet = never, RSet = never>(get: (a: NoInfer<A>) => Effect.Effect<B, EGet, RGet>, set: (a: NoInfer<A>, b: B) => Effect.Effect<NoInfer<A>, ESet, RSet>): (self: Lens<A, ER, EW, RR, RW>) => Lens<B, ER | EGet, EW | ESet, RR | RGet, RW | RSet>;
|
|
164
|
+
<A, ER, EW, RR, RW, B, EGet = never, RGet = never, ESet = never, RSet = never>(self: Lens<A, ER, EW, RR, RW>, get: (a: NoInfer<A>) => Effect.Effect<B, EGet, RGet>, set: (a: NoInfer<A>, b: B) => Effect.Effect<NoInfer<A>, ESet, RSet>): Lens<B, ER | EGet, EW | ESet, RR | RGet, RW | RSet>;
|
|
75
165
|
};
|
|
76
166
|
/**
|
|
77
167
|
* Derives a new `Lens` by applying synchronous getters and setters over the value inside an `Option`.
|
|
@@ -81,8 +171,8 @@ export declare const mapEffect: {
|
|
|
81
171
|
* - If the `Option` is `None`, it remains `None`
|
|
82
172
|
*/
|
|
83
173
|
export declare const mapOption: {
|
|
84
|
-
<A, ER, EW, RR, RW, B>(self: Lens<Option.Option<A>, ER, EW, RR, RW>, get: (a: NoInfer<A>) => B, set: (a: NoInfer<A>, b: B) => NoInfer<A>): Lens<Option.Option<B>, ER, EW, RR, RW>;
|
|
85
174
|
<A, ER, EW, RR, RW, B>(get: (a: NoInfer<A>) => B, set: (a: NoInfer<A>, b: B) => NoInfer<A>): (self: Lens<Option.Option<A>, ER, EW, RR, RW>) => Lens<Option.Option<B>, ER, EW, RR, RW>;
|
|
175
|
+
<A, ER, EW, RR, RW, B>(self: Lens<Option.Option<A>, ER, EW, RR, RW>, get: (a: NoInfer<A>) => B, set: (a: NoInfer<A>, b: B) => NoInfer<A>): Lens<Option.Option<B>, ER, EW, RR, RW>;
|
|
86
176
|
};
|
|
87
177
|
/**
|
|
88
178
|
* Derives a new `Lens` by applying effectful getters and setters over the value inside an `Option`.
|
|
@@ -92,22 +182,97 @@ export declare const mapOption: {
|
|
|
92
182
|
* - If the `Option` is `None`, it remains `None`
|
|
93
183
|
*/
|
|
94
184
|
export declare const mapOptionEffect: {
|
|
95
|
-
<A, ER, EW, RR, RW, B, EGet = never, RGet = never, ESet = never, RSet = never>(self: Lens<Option.Option<A>, ER, EW, RR, RW>, get: (a: NoInfer<A>) => Effect.Effect<B, EGet, RGet>, set: (a: NoInfer<A>, b: B) => Effect.Effect<NoInfer<A>, ESet, RSet>): Lens<Option.Option<B>, ER | EGet, EW | ESet, RR | RGet, RW | RSet>;
|
|
96
185
|
<A, ER, EW, RR, RW, B, EGet = never, RGet = never, ESet = never, RSet = never>(get: (a: NoInfer<A>) => Effect.Effect<B, EGet, RGet>, set: (a: NoInfer<A>, b: B) => Effect.Effect<NoInfer<A>, ESet, RSet>): (self: Lens<Option.Option<A>, ER, EW, RR, RW>) => Lens<Option.Option<B>, ER | EGet, EW | ESet, RR | RGet, RW | RSet>;
|
|
186
|
+
<A, ER, EW, RR, RW, B, EGet = never, RGet = never, ESet = never, RSet = never>(self: Lens<Option.Option<A>, ER, EW, RR, RW>, get: (a: NoInfer<A>) => Effect.Effect<B, EGet, RGet>, set: (a: NoInfer<A>, b: B) => Effect.Effect<NoInfer<A>, ESet, RSet>): Lens<Option.Option<B>, ER | EGet, EW | ESet, RR | RGet, RW | RSet>;
|
|
97
187
|
};
|
|
98
188
|
/**
|
|
99
189
|
* Allows transforming only the `changes` stream of a `Lens` while keeping the focus type intact.
|
|
100
190
|
*/
|
|
101
191
|
export declare const mapStream: {
|
|
102
|
-
<A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>, f: (changes: Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>) => Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>): Lens<A, ER, EW, RR, RW>;
|
|
103
192
|
<A, ER, EW, RR, RW>(f: (changes: Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>) => Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, EW, RR, RW>;
|
|
193
|
+
<A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>, f: (changes: Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>) => Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>): Lens<A, ER, EW, RR, RW>;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Transforms read errors of a `Lens`.
|
|
197
|
+
*
|
|
198
|
+
* Applies to `get` and `changes` while leaving `modify` unchanged.
|
|
199
|
+
*/
|
|
200
|
+
export declare const mapErrorRead: {
|
|
201
|
+
<A, ER, EW, RR, RW, E2>(f: (error: NoInfer<ER>) => E2): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, E2, EW, RR, RW>;
|
|
202
|
+
<A, ER, EW, RR, RW, E2>(self: Lens<A, ER, EW, RR, RW>, f: (error: NoInfer<ER>) => E2): Lens<A, E2, EW, RR, RW>;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Transforms modify errors of a `Lens`.
|
|
206
|
+
*
|
|
207
|
+
* Applies to the commit/rebuild portion of `modifyEffect` while leaving failures from the
|
|
208
|
+
* user-supplied callback unchanged.
|
|
209
|
+
*/
|
|
210
|
+
export declare const mapErrorWrite: {
|
|
211
|
+
<A, ER, EW, RR, RW, E2>(f: (error: NoInfer<EW>) => E2): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, E2, RR, RW>;
|
|
212
|
+
<A, ER, EW, RR, RW, E2>(self: Lens<A, ER, EW, RR, RW>, f: (error: NoInfer<EW>) => E2): Lens<A, ER, E2, RR, RW>;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Transforms all errors of a `Lens`.
|
|
216
|
+
*
|
|
217
|
+
* Applies to `get`, `changes`, and the commit/rebuild portion of `modifyEffect` while leaving
|
|
218
|
+
* failures from the user-supplied callback unchanged.
|
|
219
|
+
*/
|
|
220
|
+
export declare const mapError: {
|
|
221
|
+
<A, ER, EW, RR, RW, E2>(f: (error: NoInfer<ER | EW>) => E2): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, E2, E2, RR, RW>;
|
|
222
|
+
<A, ER, EW, RR, RW, E2>(self: Lens<A, ER, EW, RR, RW>, f: (error: NoInfer<ER | EW>) => E2): Lens<A, E2, E2, RR, RW>;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Runs an effect when read failures occur.
|
|
226
|
+
*
|
|
227
|
+
* Applies to `get` and `changes` while leaving `modify` unchanged.
|
|
228
|
+
*/
|
|
229
|
+
export declare const tapErrorRead: {
|
|
230
|
+
<A, ER, EW, RR, RW, B, E2, R2>(f: (error: NoInfer<ER>) => Effect.Effect<B, E2, R2>): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER | E2, EW, RR | R2, RW>;
|
|
231
|
+
<A, ER, EW, RR, RW, B, E2, R2>(self: Lens<A, ER, EW, RR, RW>, f: (error: NoInfer<ER>) => Effect.Effect<B, E2, R2>): Lens<A, ER | E2, EW, RR | R2, RW>;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Runs an effect when modify failures occur.
|
|
235
|
+
*
|
|
236
|
+
* Applies to the commit/rebuild portion of `modifyEffect` while leaving failures from the
|
|
237
|
+
* user-supplied callback unchanged.
|
|
238
|
+
*/
|
|
239
|
+
export declare const tapErrorWrite: {
|
|
240
|
+
<A, ER, EW, RR, RW, B, E2, R2>(f: (error: NoInfer<EW>) => Effect.Effect<B, E2, R2>): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, EW | E2, RR, RW | R2>;
|
|
241
|
+
<A, ER, EW, RR, RW, B, E2, R2>(self: Lens<A, ER, EW, RR, RW>, f: (error: NoInfer<EW>) => Effect.Effect<B, E2, R2>): Lens<A, ER, EW | E2, RR, RW | R2>;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Runs an effect when any `Lens` failure occurs.
|
|
245
|
+
*
|
|
246
|
+
* Applies to `get`, `changes`, and the commit/rebuild portion of `modifyEffect` while leaving
|
|
247
|
+
* failures from the user-supplied callback unchanged.
|
|
248
|
+
*/
|
|
249
|
+
export declare const tapError: {
|
|
250
|
+
<A, ER, EW, RR, RW, B, E2, R2>(f: (error: NoInfer<ER | EW>) => Effect.Effect<B, E2, R2>): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER | E2, EW | E2, RR | R2, RW | R2>;
|
|
251
|
+
<A, ER, EW, RR, RW, B, E2, R2>(self: Lens<A, ER, EW, RR, RW>, f: (error: NoInfer<ER | EW>) => Effect.Effect<B, E2, R2>): Lens<A, ER | E2, EW | E2, RR | R2, RW | R2>;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Provides a `Context` to a `Lens`, removing it from both the read and write environments.
|
|
255
|
+
*/
|
|
256
|
+
export declare const provideContext: {
|
|
257
|
+
<R2>(context: Context.Context<R2>): <A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, EW, Exclude<RR, R2>, Exclude<RW, R2>>;
|
|
258
|
+
<A, ER, EW, RR, RW, R2>(self: Lens<A, ER, EW, RR, RW>, context: Context.Context<R2>): Lens<A, ER, EW, Exclude<RR, R2>, Exclude<RW, R2>>;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Provides a single service to a `Lens`, removing it from both the read and write environments.
|
|
262
|
+
*
|
|
263
|
+
* This is the `Lens` equivalent of `Effect.provideService`: use it when a lens requires one
|
|
264
|
+
* `Context.Tag` and you already have the concrete service value.
|
|
265
|
+
*/
|
|
266
|
+
export declare const provideService: {
|
|
267
|
+
<I, S>(tag: Context.Tag<I, S>, service: NoInfer<S>): <A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, EW, Exclude<RR, I>, Exclude<RW, I>>;
|
|
268
|
+
<A, ER, EW, RR, RW, I, S>(self: Lens<A, ER, EW, RR, RW>, tag: Context.Tag<I, S>, service: NoInfer<S>): Lens<A, ER, EW, Exclude<RR, I>, Exclude<RW, I>>;
|
|
104
269
|
};
|
|
105
270
|
/**
|
|
106
271
|
* Narrows the focus to a field of an object. Replaces the object in an immutable fashion when written to.
|
|
107
272
|
*/
|
|
108
273
|
export declare const focusObjectOn: {
|
|
109
|
-
<A extends object, ER, EW, RR, RW, K extends keyof A>(self: Lens<A, ER, EW, RR, RW>, key: K): Lens<A[K], ER, EW, RR, RW>;
|
|
110
274
|
<A extends object, ER, EW, RR, RW, K extends keyof A>(key: K): (self: Lens<A, ER, EW, RR, RW>) => Lens<A[K], ER, EW, RR, RW>;
|
|
275
|
+
<A extends object, ER, EW, RR, RW, K extends keyof A>(self: Lens<A, ER, EW, RR, RW>, key: K): Lens<A[K], ER, EW, RR, RW>;
|
|
111
276
|
};
|
|
112
277
|
export declare namespace focusObjectOnWritable {
|
|
113
278
|
type WritableKeys<T> = {
|
|
@@ -123,48 +288,85 @@ export declare namespace focusObjectOnWritable {
|
|
|
123
288
|
* Narrows the focus to a writable field of an object. Mutates the object in place when written to.
|
|
124
289
|
*/
|
|
125
290
|
export declare const focusObjectOnWritable: {
|
|
126
|
-
<A extends object, ER, EW, RR, RW, K extends focusObjectOnWritable.WritableKeys<A>>(self: Lens<A, ER, EW, RR, RW>, key: K): Lens<A[K], ER, EW, RR, RW>;
|
|
127
291
|
<A extends object, ER, EW, RR, RW, K extends focusObjectOnWritable.WritableKeys<A>>(key: K): (self: Lens<A, ER, EW, RR, RW>) => Lens<A[K], ER, EW, RR, RW>;
|
|
292
|
+
<A extends object, ER, EW, RR, RW, K extends focusObjectOnWritable.WritableKeys<A>>(self: Lens<A, ER, EW, RR, RW>, key: K): Lens<A[K], ER, EW, RR, RW>;
|
|
128
293
|
};
|
|
129
294
|
/**
|
|
130
295
|
* Narrows the focus to an indexed element of an array. Replaces the array in an immutable fashion when written to.
|
|
131
296
|
*/
|
|
132
297
|
export declare const focusArrayAt: {
|
|
133
|
-
<A extends readonly any[], ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>, index: number): Lens<A[number], ER | NoSuchElementException, EW | NoSuchElementException, RR, RW>;
|
|
134
298
|
<A extends readonly any[], ER, EW, RR, RW>(index: number): (self: Lens<A, ER, EW, RR, RW>) => Lens<A[number], ER | NoSuchElementException, EW | NoSuchElementException, RR, RW>;
|
|
299
|
+
<A extends readonly any[], ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>, index: number): Lens<A[number], ER | NoSuchElementException, EW | NoSuchElementException, RR, RW>;
|
|
135
300
|
};
|
|
136
301
|
/**
|
|
137
302
|
* Narrows the focus to an indexed element of a mutable array. Mutates the array in place when written to.
|
|
138
303
|
*/
|
|
139
304
|
export declare const focusMutableArrayAt: {
|
|
140
|
-
<A, ER, EW, RR, RW>(self: Lens<A[], ER, EW, RR, RW>, index: number): Lens<A, ER | NoSuchElementException, EW | NoSuchElementException, RR, RW>;
|
|
141
305
|
<A, ER, EW, RR, RW>(index: number): (self: Lens<A[], ER, EW, RR, RW>) => Lens<A, ER | NoSuchElementException, EW | NoSuchElementException, RR, RW>;
|
|
306
|
+
<A, ER, EW, RR, RW>(self: Lens<A[], ER, EW, RR, RW>, index: number): Lens<A, ER | NoSuchElementException, EW | NoSuchElementException, RR, RW>;
|
|
142
307
|
};
|
|
143
308
|
/**
|
|
144
309
|
* Narrows the focus to an indexed element of a readonly tuple. Replaces the tuple in an immutable fashion when written to.
|
|
145
310
|
*/
|
|
146
311
|
export declare const focusTupleAt: {
|
|
147
|
-
<T extends readonly [any, ...any[]], ER, EW, RR, RW, I extends number>(self: Lens<T, ER, EW, RR, RW>, index: I): Lens<T[I], ER, EW, RR, RW>;
|
|
148
312
|
<T extends readonly [any, ...any[]], ER, EW, RR, RW, I extends number>(index: I): (self: Lens<T, ER, EW, RR, RW>) => Lens<T[I], ER, EW, RR, RW>;
|
|
313
|
+
<T extends readonly [any, ...any[]], ER, EW, RR, RW, I extends number>(self: Lens<T, ER, EW, RR, RW>, index: I): Lens<T[I], ER, EW, RR, RW>;
|
|
149
314
|
};
|
|
150
315
|
/**
|
|
151
316
|
* Narrows the focus to an indexed element of a mutable tuple. Mutates the tuple in place when written to.
|
|
152
317
|
*/
|
|
153
318
|
export declare const focusMutableTupleAt: {
|
|
154
|
-
<T extends [any, ...any[]], ER, EW, RR, RW, I extends number>(self: Lens<T, ER, EW, RR, RW>, index: I): Lens<T[I], ER, EW, RR, RW>;
|
|
155
319
|
<T extends [any, ...any[]], ER, EW, RR, RW, I extends number>(index: I): (self: Lens<T, ER, EW, RR, RW>) => Lens<T[I], ER, EW, RR, RW>;
|
|
320
|
+
<T extends [any, ...any[]], ER, EW, RR, RW, I extends number>(self: Lens<T, ER, EW, RR, RW>, index: I): Lens<T[I], ER, EW, RR, RW>;
|
|
156
321
|
};
|
|
157
322
|
/**
|
|
158
323
|
* Narrows the focus to an indexed element of `Chunk`. Replaces the `Chunk` in an immutable fashion when written to.
|
|
159
324
|
*/
|
|
160
325
|
export declare const focusChunkAt: {
|
|
161
|
-
<A, ER, EW, RR, RW>(self: Lens<Chunk.Chunk<A>, ER, EW, RR, RW>, index: number): Lens<A, ER | NoSuchElementException, EW, RR, RW>;
|
|
162
326
|
<A, ER, EW, RR, RW>(index: number): (self: Lens<Chunk.Chunk<A>, ER, EW, RR, RW>) => Lens<A, ER | NoSuchElementException, EW, RR, RW>;
|
|
327
|
+
<A, ER, EW, RR, RW>(self: Lens<Chunk.Chunk<A>, ER, EW, RR, RW>, index: number): Lens<A, ER | NoSuchElementException, EW, RR, RW>;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Narrows the focus to the value inside an `Option`.
|
|
331
|
+
*
|
|
332
|
+
* Reading or writing through this lens fails with `NoSuchElementException` when the parent option is `None`.
|
|
333
|
+
* Writing wraps the new focused value back into `Option.some`.
|
|
334
|
+
*/
|
|
335
|
+
export declare const focusOption: {
|
|
336
|
+
<A, ER, EW, RR, RW>(self: Lens<Option.Option<A>, ER, EW, RR, RW>): Lens<A, ER | NoSuchElementException, EW | NoSuchElementException, RR, RW>;
|
|
163
337
|
};
|
|
164
338
|
/**
|
|
165
339
|
* Reads the current value from a `Lens`.
|
|
166
340
|
*/
|
|
167
341
|
export declare const get: <A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<A, ER, RR>;
|
|
342
|
+
/**
|
|
343
|
+
* Atomically modifies the value of a `Lens` and returns a computed result.
|
|
344
|
+
*/
|
|
345
|
+
export declare const modify: {
|
|
346
|
+
<A, B>(f: (a: A) => readonly [B, A]): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<B, ER | EW, RR | RW>;
|
|
347
|
+
<A, ER, EW, RR, RW, B>(self: Lens<A, ER, EW, RR, RW>, f: (a: A) => readonly [B, A]): Effect.Effect<B, ER | EW, RR | RW>;
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Atomically modifies the value of a `Lens` with an effect and returns a computed result.
|
|
351
|
+
*/
|
|
352
|
+
export declare const modifyEffect: {
|
|
353
|
+
<A, B, E, R>(f: (a: A) => Effect.Effect<readonly [B, A], E, R>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<B, ER | EW | E, RR | RW | R>;
|
|
354
|
+
<A, ER, EW, RR, RW, B, E, R>(self: Lens<A, ER, EW, RR, RW>, f: (a: A) => Effect.Effect<readonly [B, A], E, R>): Effect.Effect<B, ER | EW | E, RR | RW | R>;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Conditionally modifies the value of a `Lens`, returning `fallback` when the function returns `None`.
|
|
358
|
+
*/
|
|
359
|
+
export declare const modifySome: {
|
|
360
|
+
<B, A>(fallback: B, pf: (a: NoInfer<A>) => Option.Option<readonly [B, NoInfer<A>]>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<B, ER | EW, RR | RW>;
|
|
361
|
+
<A, ER, EW, RR, RW, B>(self: Lens<A, ER, EW, RR, RW>, fallback: B, pf: (a: A) => Option.Option<readonly [B, A]>): Effect.Effect<B, ER | EW, RR | RW>;
|
|
362
|
+
};
|
|
363
|
+
/**
|
|
364
|
+
* Conditionally modifies the value of a `Lens` with an effect, returning `fallback` when the function returns `None`.
|
|
365
|
+
*/
|
|
366
|
+
export declare const modifySomeEffect: {
|
|
367
|
+
<B, A, E = never, R = never>(fallback: B, pf: (a: NoInfer<A>) => Option.Option<Effect.Effect<readonly [B, NoInfer<A>], E, R>>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<B, ER | EW | E, RR | RW | R>;
|
|
368
|
+
<A, ER, EW, RR, RW, B, E = never, R = never>(self: Lens<A, ER, EW, RR, RW>, fallback: B, pf: (a: A) => Option.Option<Effect.Effect<readonly [B, A], E, R>>): Effect.Effect<B, ER | EW | E, RR | RW | R>;
|
|
369
|
+
};
|
|
168
370
|
/**
|
|
169
371
|
* Sets the value of a `Lens`.
|
|
170
372
|
*/
|
|
@@ -207,6 +409,20 @@ export declare const getAndUpdateEffect: {
|
|
|
207
409
|
<A, ER, EW, RR, RW, E, R>(f: (a: A) => Effect.Effect<A, E, R>): (self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
208
410
|
<A, ER, EW, RR, RW, E, R>(self: Lens<A, ER, EW, RR, RW>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
209
411
|
};
|
|
412
|
+
/**
|
|
413
|
+
* Conditionally updates a `Lens` and returns the previous value.
|
|
414
|
+
*/
|
|
415
|
+
export declare const getAndUpdateSome: {
|
|
416
|
+
<A>(pf: (a: NoInfer<A>) => Option.Option<NoInfer<A>>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<A, ER | EW, RR | RW>;
|
|
417
|
+
<A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>, pf: (a: A) => Option.Option<A>): Effect.Effect<A, ER | EW, RR | RW>;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* Conditionally updates a `Lens` with an effect and returns the previous value.
|
|
421
|
+
*/
|
|
422
|
+
export declare const getAndUpdateSomeEffect: {
|
|
423
|
+
<A, E = never, R = never>(pf: (a: NoInfer<A>) => Option.Option<Effect.Effect<NoInfer<A>, E, R>>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
424
|
+
<A, ER, EW, RR, RW, E = never, R = never>(self: Lens<A, ER, EW, RR, RW>, pf: (a: A) => Option.Option<Effect.Effect<A, E, R>>): Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
425
|
+
};
|
|
210
426
|
/**
|
|
211
427
|
* Sets the value of a `Lens` and returns the new value.
|
|
212
428
|
*/
|
|
@@ -228,4 +444,32 @@ export declare const updateAndGetEffect: {
|
|
|
228
444
|
<A, ER, EW, RR, RW, E, R>(f: (a: A) => Effect.Effect<A, E, R>): (self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
229
445
|
<A, ER, EW, RR, RW, E, R>(self: Lens<A, ER, EW, RR, RW>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
230
446
|
};
|
|
447
|
+
/**
|
|
448
|
+
* Conditionally updates the value of a `Lens`.
|
|
449
|
+
*/
|
|
450
|
+
export declare const updateSome: {
|
|
451
|
+
<A>(pf: (a: NoInfer<A>) => Option.Option<NoInfer<A>>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<void, ER | EW, RR | RW>;
|
|
452
|
+
<A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>, pf: (a: A) => Option.Option<A>): Effect.Effect<void, ER | EW, RR | RW>;
|
|
453
|
+
};
|
|
454
|
+
/**
|
|
455
|
+
* Conditionally updates the value of a `Lens` with an effect.
|
|
456
|
+
*/
|
|
457
|
+
export declare const updateSomeEffect: {
|
|
458
|
+
<A, E = never, R = never>(pf: (a: NoInfer<A>) => Option.Option<Effect.Effect<NoInfer<A>, E, R>>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<void, ER | EW | E, RR | RW | R>;
|
|
459
|
+
<A, ER, EW, RR, RW, E = never, R = never>(self: Lens<A, ER, EW, RR, RW>, pf: (a: A) => Option.Option<Effect.Effect<A, E, R>>): Effect.Effect<void, ER | EW | E, RR | RW | R>;
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* Conditionally updates a `Lens` and returns the resulting value.
|
|
463
|
+
*/
|
|
464
|
+
export declare const updateSomeAndGet: {
|
|
465
|
+
<A>(pf: (a: NoInfer<A>) => Option.Option<NoInfer<A>>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<A, ER | EW, RR | RW>;
|
|
466
|
+
<A, ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>, pf: (a: A) => Option.Option<A>): Effect.Effect<A, ER | EW, RR | RW>;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Conditionally updates a `Lens` with an effect and returns the resulting value.
|
|
470
|
+
*/
|
|
471
|
+
export declare const updateSomeAndGetEffect: {
|
|
472
|
+
<A, E = never, R = never>(pf: (a: NoInfer<A>) => Option.Option<Effect.Effect<NoInfer<A>, E, R>>): <ER, EW, RR, RW>(self: Lens<A, ER, EW, RR, RW>) => Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
473
|
+
<A, ER, EW, RR, RW, E = never, R = never>(self: Lens<A, ER, EW, RR, RW>, pf: (a: A) => Option.Option<Effect.Effect<A, E, R>>): Effect.Effect<A, ER | EW | E, RR | RW | R>;
|
|
474
|
+
};
|
|
231
475
|
export {};
|