@@ -1,12 +1,15 @@
|
||||
import { Effect, Pipeable, Predicate, Readable, Stream, Subscribable, type SubscriptionRef } from "effect"
|
||||
import * as Writable from "./Writable.js"
|
||||
|
||||
|
||||
export const LensTypeId: unique symbol = Symbol.for("@effect-fc/Lens/Lens")
|
||||
export type LensTypeId = typeof LensTypeId
|
||||
|
||||
export interface Lens<in out A, ER = never, RR = never, EW = never, RW = never>
|
||||
extends LensPrototype, Subscribable.Subscribable<A, ER, RR>, Writable.Writable<A, EW, RW> {}
|
||||
extends Subscribable.Subscribable<A, ER, RR>, LensPrototype {
|
||||
readonly modify: <B, E1 = never, R1 = never>(
|
||||
f: (a: A) => Effect.Effect<readonly [B, A], E1, R1>
|
||||
) => Effect.Effect<B, ER | EW | E1, RR | RW | R1>
|
||||
}
|
||||
|
||||
|
||||
export interface LensPrototype extends Pipeable.Pipeable {
|
||||
@@ -15,7 +18,6 @@ export interface LensPrototype extends Pipeable.Pipeable {
|
||||
|
||||
export const LensPrototype: LensPrototype = Object.freeze({
|
||||
...Pipeable.Prototype,
|
||||
...Writable.WritablePrototype,
|
||||
[Readable.TypeId]: Readable.TypeId,
|
||||
[Subscribable.TypeId]: Subscribable.TypeId,
|
||||
[LensTypeId]: LensTypeId,
|
||||
@@ -29,8 +31,8 @@ export const make = <A, ER, RR, EW, RW>(
|
||||
readonly get: Effect.Effect<A, ER, RR>
|
||||
readonly changes: Stream.Stream<A, ER, RR>
|
||||
} & (
|
||||
| { readonly modify: <B, E1 = never, R1 = never>(f: (a: A) => Effect.Effect<readonly [B, A], E1, R1>) => Effect.Effect<B, EW | E1, RW | R1> }
|
||||
| { readonly set: (value: A) => Effect.Effect<void, EW, RW> }
|
||||
| { readonly modify: <B, E1 = never, R1 = never>(f: (a: A) => Effect.Effect<readonly [B, A], E1, R1>) => Effect.Effect<B, ER | EW | E1, RR | RW | R1> }
|
||||
)
|
||||
): Lens<A, ER, RR, EW, RW> => Object.setPrototypeOf({
|
||||
get: options.get,
|
||||
|
||||
Reference in New Issue
Block a user