diff --git a/packages/effect-lens/src/Lens.ts b/packages/effect-lens/src/Lens.ts index 77b7b54..52035ee 100644 --- a/packages/effect-lens/src/Lens.ts +++ b/packages/effect-lens/src/Lens.ts @@ -27,6 +27,10 @@ extends Subscribable.Subscribable { */ export const isLens = (u: unknown): u is Lens => 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 = ( } -export declare namespace LensImpl { - export interface Source { - readonly get: Effect.Effect, - readonly changes: Stream.Stream, - readonly update: (a: A) => Effect.Effect, - readonly withLock: (self: Effect.Effect) => Effect.Effect, - } -} - -export class LensImpl -extends Pipeable.Class() implements LensWithInternals { +export abstract class LensImpl +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 - readonly changes: Stream.Stream - readonly update: (a: A) => Effect.Effect - readonly withLock: (self: Effect.Effect) => Effect.Effect - - constructor( - source: LensImpl.Source - ) { - super() - - this.get = source.get - this.changes = source.changes - this.update = source.update - this.withLock = source.withLock - } + abstract readonly get: Effect.Effect + abstract readonly changes: Stream.Stream + abstract readonly update: (a: A) => Effect.Effect + abstract readonly withLock: (self: Effect.Effect) => Effect.Effect modifyEffect = modifyEffect } +// export declare namespace LensImpl { +// export interface Source { +// readonly get: Effect.Effect, +// readonly changes: Stream.Stream, +// readonly update: (a: A) => Effect.Effect, +// readonly withLock: (self: Effect.Effect) => Effect.Effect, +// } +// } + +// export class LensImpl +// extends Pipeable.Class() implements LensWithInternals { +// 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 +// readonly changes: Stream.Stream +// readonly update: (a: A) => Effect.Effect +// readonly withLock: (self: Effect.Effect) => Effect.Effect + +// constructor( +// source: LensImpl.Source +// ) { +// super() + +// this.get = source.get +// this.changes = source.changes +// this.update = source.update +// this.withLock = source.withLock +// } + +// modifyEffect = modifyEffect +// } + function modifyEffect( this: LensWithInternals, f: (a: A) => Effect.Effect,