@@ -27,6 +27,10 @@ extends Subscribable.Subscribable<A, ER, RR> {
|
||||
*/
|
||||
export const isLens = (u: unknown): u is Lens<unknown, unknown, unknown, unknown, unknown> => Predicate.hasProperty(u, LensTypeId)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const LensWithInternalsTypeId: unique symbol = Symbol.for("@effect-fc/Lens/LensWithInternals")
|
||||
export type LensWithInternalsTypeId = typeof LensWithInternalsTypeId
|
||||
|
||||
@@ -49,41 +53,56 @@ export const asLensWithInternals = <A, ER, EW, RR, RW>(
|
||||
}
|
||||
|
||||
|
||||
export declare namespace LensImpl {
|
||||
export interface Source<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never> {
|
||||
readonly get: Effect.Effect<A, ER, RR>,
|
||||
readonly changes: Stream.Stream<A, ER, RR>,
|
||||
readonly update: (a: A) => Effect.Effect<void, EW, RW>,
|
||||
readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, EW | E1, RW | R1>,
|
||||
}
|
||||
}
|
||||
|
||||
export class LensImpl<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never>
|
||||
extends Pipeable.Class() implements LensWithInternals<A, ER, EW, RR, RW> {
|
||||
export abstract class LensImpl<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never>
|
||||
extends Pipeable.Class() {
|
||||
readonly [Readable.TypeId]: Readable.TypeId = Readable.TypeId
|
||||
readonly [Subscribable.TypeId]: Subscribable.TypeId = Subscribable.TypeId
|
||||
readonly [LensTypeId]: LensTypeId = LensTypeId
|
||||
readonly [LensWithInternalsTypeId]: LensWithInternalsTypeId = LensWithInternalsTypeId
|
||||
|
||||
readonly get: Effect.Effect<A, ER, RR>
|
||||
readonly changes: Stream.Stream<A, ER, RR>
|
||||
readonly update: (a: A) => Effect.Effect<void, EW, RW>
|
||||
readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, EW | E1, RW | R1>
|
||||
|
||||
constructor(
|
||||
source: LensImpl.Source<A, ER, EW, RR, RW>
|
||||
) {
|
||||
super()
|
||||
|
||||
this.get = source.get
|
||||
this.changes = source.changes
|
||||
this.update = source.update
|
||||
this.withLock = source.withLock
|
||||
}
|
||||
abstract readonly get: Effect.Effect<A, ER, RR>
|
||||
abstract readonly changes: Stream.Stream<A, ER, RR>
|
||||
abstract readonly update: (a: A) => Effect.Effect<void, EW, RW>
|
||||
abstract readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, EW | E1, RW | R1>
|
||||
|
||||
modifyEffect = modifyEffect
|
||||
}
|
||||
|
||||
// export declare namespace LensImpl {
|
||||
// export interface Source<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never> {
|
||||
// readonly get: Effect.Effect<A, ER, RR>,
|
||||
// readonly changes: Stream.Stream<A, ER, RR>,
|
||||
// readonly update: (a: A) => Effect.Effect<void, EW, RW>,
|
||||
// readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, EW | E1, RW | R1>,
|
||||
// }
|
||||
// }
|
||||
|
||||
// export class LensImpl<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never>
|
||||
// extends Pipeable.Class() implements LensWithInternals<A, ER, EW, RR, RW> {
|
||||
// readonly [Readable.TypeId]: Readable.TypeId = Readable.TypeId
|
||||
// readonly [Subscribable.TypeId]: Subscribable.TypeId = Subscribable.TypeId
|
||||
// readonly [LensTypeId]: LensTypeId = LensTypeId
|
||||
// readonly [LensWithInternalsTypeId]: LensWithInternalsTypeId = LensWithInternalsTypeId
|
||||
|
||||
// readonly get: Effect.Effect<A, ER, RR>
|
||||
// readonly changes: Stream.Stream<A, ER, RR>
|
||||
// readonly update: (a: A) => Effect.Effect<void, EW, RW>
|
||||
// readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, EW | E1, RW | R1>
|
||||
|
||||
// constructor(
|
||||
// source: LensImpl.Source<A, ER, EW, RR, RW>
|
||||
// ) {
|
||||
// super()
|
||||
|
||||
// this.get = source.get
|
||||
// this.changes = source.changes
|
||||
// this.update = source.update
|
||||
// this.withLock = source.withLock
|
||||
// }
|
||||
|
||||
// modifyEffect = modifyEffect
|
||||
// }
|
||||
|
||||
function modifyEffect<A, B, ER = never, EW = never, E1 = never, RR = never, RW = never, R1 = never>(
|
||||
this: LensWithInternals<A, ER, EW, RR, RW>,
|
||||
f: (a: A) => Effect.Effect<readonly [B, A], E1, R1>,
|
||||
|
||||
Reference in New Issue
Block a user