From 595a51a8711ca576c4f3112771f78c71c75aec5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Sat, 30 May 2026 05:24:24 +0200 Subject: [PATCH] Refactor --- packages/effect-lens/src/Lens.ts | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/packages/effect-lens/src/Lens.ts b/packages/effect-lens/src/Lens.ts index 0a87838..6e4ae57 100644 --- a/packages/effect-lens/src/Lens.ts +++ b/packages/effect-lens/src/Lens.ts @@ -373,16 +373,16 @@ export const mapEffect: { ( self: Lens, get: (a: NoInfer) => Effect.Effect, - update: (a: NoInfer, b: B) => Effect.Effect, ESet, RSet>, + set: (a: NoInfer, b: B) => Effect.Effect, ESet, RSet>, ): Lens ( get: (a: NoInfer) => Effect.Effect, - update: (a: NoInfer, b: B) => Effect.Effect, ESet, RSet>, + set: (a: NoInfer, b: B) => Effect.Effect, ESet, RSet>, ): (self: Lens) => Lens } = Function.dual(3, ( self: Lens, get: (a: NoInfer) => Effect.Effect, - update: (a: NoInfer, b: B) => Effect.Effect, ESet, RSet>, + set: (a: NoInfer, b: B) => Effect.Effect, ESet, RSet>, ): Lens => derive(self, { resolve: parent => Effect.flatMap( parent, @@ -390,12 +390,12 @@ export const mapEffect: { get(frame.value), value => ({ value, - commit: next => frame.commit(Effect.flatMap(next, b => update(frame.value, b))), + commit: next => frame.commit(Effect.flatMap(next, b => set(frame.value, b))), }), ), ), mapStream: Stream.mapEffect(get), - mapLock: lock => lock as Effect.Effect, + mapLock: identity>, })) /** @@ -643,7 +643,7 @@ export const tapErrorRead: { ): Lens => derive(self, { resolve: Effect.tapError(f), mapStream: Stream.tapError(f), - mapLock: lock => lock, + mapLock: identity, })) /** @@ -672,7 +672,7 @@ export const tapErrorWrite: { ), })), mapStream: identity, - mapLock: lock => Effect.tapError(lock, f), + mapLock: Effect.tapError(f), })) /** @@ -704,7 +704,7 @@ export const tapError: { }), ), mapStream: Stream.tapError(f), - mapLock: lock => Effect.tapError(lock, f), + mapLock: Effect.tapError(f), })) @@ -727,14 +727,11 @@ export const provideContext: { Effect.provide(parent, context), frame => ({ value: frame.value, - commit: next => Effect.provide(frame.commit(Effect.provide(next, context)), context), + commit: next => Effect.provide(frame.commit(next), context), }), ), mapStream: Stream.provideSomeContext(context), - mapLock: lock => Effect.map( - Effect.provide(lock, context), - lock => self => Effect.provide(lock(Effect.provide(self, context)), context), - ), + mapLock: Effect.provide(context), })) /** @@ -762,14 +759,11 @@ export const provideService: { Effect.provideService(parent, tag, service), frame => ({ value: frame.value, - commit: next => Effect.provideService(frame.commit(Effect.provideService(next, tag, service)), tag, service), + commit: next => Effect.provideService(frame.commit(next), tag, service), }), ), mapStream: Stream.provideService(tag, service), - mapLock: lock => Effect.map( - Effect.provideService(lock, tag, service), - lock => self => Effect.provideService(lock(Effect.provideService(self, tag, service)), tag, service), - ), + mapLock: Effect.provideService(tag, service), }))