0.2.0 #5
@@ -40,19 +40,6 @@ export interface LensStep<in out A, in out B, in out ER = never, in out EW = nev
|
||||
export const isLensStep = (u: unknown): u is LensStep<unknown, unknown, unknown, unknown, unknown, unknown> => Predicate.hasProperty(u, LensStepTypeId)
|
||||
|
||||
|
||||
// export const LensWithInternalsTypeId: unique symbol = Symbol.for("@effect-fc/Lens/LensWithInternals")
|
||||
// export type LensWithInternalsTypeId = typeof LensWithInternalsTypeId
|
||||
|
||||
// export interface LensWithInternals<in out A, in out ER = never, in out EW = never, in out RR = never, in out RW = never>
|
||||
// extends Lens<A, ER, EW, RR, RW> {
|
||||
// readonly [LensWithInternalsTypeId]: LensWithInternalsTypeId
|
||||
|
||||
// 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 const isLensWithInternals = (u: unknown): u is LensWithInternals<unknown, unknown, unknown, unknown, unknown> => Predicate.hasProperty(u, LensWithInternalsTypeId)
|
||||
|
||||
// export const asLensWithInternals = <A, ER, EW, RR, RW>(
|
||||
// lens: Lens<A, ER, EW, RR, RW>
|
||||
// ): LensWithInternals<A, ER, EW, RR, RW> => {
|
||||
@@ -74,13 +61,17 @@ extends Pipeable.Class() implements Lens<A, ER, EW, RR, RW> {
|
||||
|
||||
readonly steps: readonly LensStep<A, ER, EW, RR, RW>[] = []
|
||||
|
||||
abstract readonly read: Effect.Effect<A, ER, RR>
|
||||
abstract readonly changes: Stream.Stream<A, ER, RR>
|
||||
abstract readonly commit: (a: A) => Effect.Effect<void, EW, RW>
|
||||
abstract readonly sourceGet: Effect.Effect<A, ER, RR>
|
||||
abstract readonly sourceChanges: Stream.Stream<A, ER, RR>
|
||||
abstract readonly sourceCommit: (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>
|
||||
|
||||
get get(): Effect.Effect<A, ER, RR> {
|
||||
return this.sourceGet
|
||||
}
|
||||
|
||||
get changes(): Stream.Stream<A, ER, RR> {
|
||||
return this.sourceChanges
|
||||
}
|
||||
|
||||
modifyEffect<B, E1 = never, R1 = never>(
|
||||
@@ -88,7 +79,7 @@ extends Pipeable.Class() implements Lens<A, ER, EW, RR, RW> {
|
||||
): Effect.Effect<B, ER | EW | E1, RR | RW | R1> {
|
||||
return this.withLock(Effect.flatMap(
|
||||
this.get,
|
||||
a => Effect.flatMap(f(a), ([b, next]) => Effect.as(this.commit(next), b),
|
||||
a => Effect.flatMap(f(a), ([b, next]) => Effect.as(this.sourceCommit(next), b),
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user