diff --git a/packages/effect-fc/src/Lens.ts b/packages/effect-fc/src/Lens.ts
index dc73344..f7f98c6 100644
--- a/packages/effect-fc/src/Lens.ts
+++ b/packages/effect-fc/src/Lens.ts
@@ -137,6 +137,23 @@ export const mapEffect: {
)),
}))
+export const mapStructAt: {
+ (
+ self: Lens,
+ key: K,
+ ): Lens
+ (
+ key: K,
+ ): (self: Lens) => Lens
+} = Function.dual(2, (
+ self: Lens,
+ key: K,
+): Lens => map(
+ self,
+ a => a[key],
+ (a, b) => Object.setPrototypeOf({ ...a, [key]: b }, Object.getPrototypeOf(a)),
+))
+
export const mapArrayAt: {
(
self: Lens,
@@ -275,14 +292,15 @@ Effect.gen(function*() {
values: [13, 69, 1488]
})
- const myValueLens = myChunkRef.pipe(
+ const myValueLens = ref.pipe(
fromSubscriptionRef,
- mapChunkAt(1),
+ mapStructAt("values"),
+ mapArrayAt(1),
)
- console.log(yield* myChunkRef.get, yield* chunkValueLens.get)
- yield* set(chunkValueLens, 22)
- console.log(yield* myChunkRef.get, yield* chunkValueLens.get)
+ console.log(yield* ref.get, yield* myValueLens.get)
+ yield* set(myValueLens, 22)
+ console.log(yield* ref.get, yield* myValueLens.get)
}).pipe(
Effect.runSync
)