From f1d0771356e4345c0dd4113b2f80a32d1e837b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Tue, 24 Mar 2026 11:51:38 +0100 Subject: [PATCH] Fix --- packages/effect-fc/src/Lens.test.ts | 20 ++++++++++---------- packages/effect-fc/src/Lens.ts | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/effect-fc/src/Lens.test.ts b/packages/effect-fc/src/Lens.test.ts index 5ca7147..208d74a 100644 --- a/packages/effect-fc/src/Lens.test.ts +++ b/packages/effect-fc/src/Lens.test.ts @@ -4,12 +4,12 @@ import * as Lens from "./Lens.js" describe("Lens", () => { - test("mapField focuses a nested property without touching other fields", async () => { + test("focusField focuses a nested property without touching other fields", async () => { const [initialCount, updatedState] = await Effect.runPromise( Effect.flatMap( SubscriptionRef.make({ count: 1, label: "original" }), parent => { - const countLens = Lens.mapField(Lens.fromSubscriptionRef(parent), "count") + const countLens = Lens.focusField(Lens.fromSubscriptionRef(parent), "count") return Effect.flatMap( Lens.get(countLens), count => Effect.flatMap( @@ -25,13 +25,13 @@ describe("Lens", () => { expect(updatedState).toEqual({ count: 6, label: "original" }) }) - test("mapMutableField preserves the root identity when mutating in place", async () => { + test("focusMutableField preserves the root identity when mutating in place", async () => { const original = { detail: "keep" } const updated = await Effect.runPromise( Effect.flatMap( SubscriptionRef.make(original), parent => { - const detailLens = Lens.mapMutableField(Lens.fromSubscriptionRef(parent), "detail") + const detailLens = Lens.focusMutableField(Lens.fromSubscriptionRef(parent), "detail") return Effect.flatMap( Lens.set(detailLens, "mutated"), () => parent.get, @@ -44,12 +44,12 @@ describe("Lens", () => { expect(updated.detail).toBe("mutated") }) - test("mapArrayAt updates the selected index", async () => { + test("focusArrayAt updates the selected index", async () => { const updated = await Effect.runPromise( Effect.flatMap( SubscriptionRef.make([10, 20, 30]), parent => { - const elementLens = Lens.mapArrayAt(Lens.fromSubscriptionRef(parent), 1) + const elementLens = Lens.focusArrayAt(Lens.fromSubscriptionRef(parent), 1) return Effect.flatMap( Lens.update(elementLens, value => value + 5), () => parent.get, @@ -61,13 +61,13 @@ describe("Lens", () => { expect(updated).toEqual([10, 25, 30]) }) - test("mapMutableArrayAt mutates the array reference in place", async () => { + test("focusMutableArrayAt mutates the array reference in place", async () => { const original = ["foo", "bar"] const updated = await Effect.runPromise( Effect.flatMap( SubscriptionRef.make(original), parent => { - const elementLens = Lens.mapMutableArrayAt(Lens.fromSubscriptionRef(parent), 0) + const elementLens = Lens.focusMutableArrayAt(Lens.fromSubscriptionRef(parent), 0) return Effect.flatMap( Lens.set(elementLens, "baz"), () => parent.get, @@ -80,12 +80,12 @@ describe("Lens", () => { expect(updated).toEqual(["baz", "bar"]) }) - test("mapChunkAt replaces the focused chunk element", async () => { + test("focusChunkAt replaces the focused chunk element", async () => { const updated = await Effect.runPromise( Effect.flatMap( SubscriptionRef.make(Chunk.make(1, 2, 3) as Chunk.Chunk), parent => { - const elementLens = Lens.mapChunkAt(Lens.fromSubscriptionRef(parent), 2) + const elementLens = Lens.focusChunkAt(Lens.fromSubscriptionRef(parent), 2) return Effect.flatMap( Lens.set(elementLens, 99), () => parent.get, diff --git a/packages/effect-fc/src/Lens.ts b/packages/effect-fc/src/Lens.ts index 3c8e23f..1b2f19a 100644 --- a/packages/effect-fc/src/Lens.ts +++ b/packages/effect-fc/src/Lens.ts @@ -157,7 +157,7 @@ export const mapStream: { })) -export const mapField: { +export const focusField: { ( self: Lens, key: K, @@ -174,7 +174,7 @@ export const mapField: { (a, b) => Object.setPrototypeOf({ ...a, [key]: b }, Object.getPrototypeOf(a)), )) -export declare namespace mapMutableField { +export declare namespace focusMutableField { export type WritableKeys = { [K in keyof T]-?: IfEquals< { [P in K]: T[K] }, @@ -187,20 +187,20 @@ export declare namespace mapMutableField { type IfEquals = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? A : B } -export const mapMutableField: { - , ER, EW, RR, RW>( +export const focusMutableField: { + , ER, EW, RR, RW>( self: Lens, key: K, ): Lens - , ER, EW, RR, RW>( + , ER, EW, RR, RW>( key: K, ): (self: Lens) => Lens -} = Function.dual(2, , ER, EW, RR, RW>( +} = Function.dual(2, , ER, EW, RR, RW>( self: Lens, key: K, ): Lens => map(self, a => a[key], (a, b) => { a[key] = b; return a })) -export const mapArrayAt: { +export const focusArrayAt: { ( self: Lens, index: number, @@ -217,7 +217,7 @@ export const mapArrayAt: { (a, b) => Array.replaceOption(a, index, b) as any, )) -export const mapMutableArrayAt: { +export const focusMutableArrayAt: { ( self: Lens, index: number, @@ -237,7 +237,7 @@ export const mapMutableArrayAt: { ), )) -export const mapChunkAt: { +export const focusChunkAt: { ( self: Lens, ER, EW, RR, RW>, index: number,