diff --git a/packages/effect-lens/package.json b/packages/effect-lens/package.json
index f5b0f5f..5e3a238 100644
--- a/packages/effect-lens/package.json
+++ b/packages/effect-lens/package.json
@@ -1,7 +1,7 @@
{
"name": "effect-lens",
"description": "An effectful Lens type to easily manage nested state",
- "version": "0.1.3",
+ "version": "0.1.4",
"type": "module",
"files": [
"./README.md",
diff --git a/packages/effect-lens/src/Lens.ts b/packages/effect-lens/src/Lens.ts
index f265eee..bdb5ffe 100644
--- a/packages/effect-lens/src/Lens.ts
+++ b/packages/effect-lens/src/Lens.ts
@@ -274,14 +274,14 @@ export const mapStream: {
* Narrows the focus to a field of an object. Replaces the object in an immutable fashion when written to.
*/
export const focusObjectField: {
- (
+ (
self: Lens,
key: K,
): Lens
- (
+ (
key: K,
): (self: Lens) => Lens
-} = Function.dual(2, (
+} = Function.dual(2, (
self: Lens,
key: K,
): Lens => map(
@@ -307,14 +307,14 @@ export declare namespace focusObjectMutableField {
* Narrows the focus to a mutable field of an object. Mutates the object in place when written to.
*/
export const focusObjectMutableField: {
- , ER, EW, RR, RW>(
+ >(
self: Lens,
key: K,
): Lens
- , ER, EW, RR, RW>(
+ >(
key: K,
): (self: Lens) => Lens
-} = Function.dual(2, , ER, EW, RR, RW>(
+} = Function.dual(2, >(
self: Lens,
key: K,
): Lens => map(self, a => a[key], (a, b) => { a[key] = b; return a }))
@@ -366,14 +366,14 @@ export const focusMutableArrayAt: {
* Narrows the focus to an indexed element of a readonly tuple. Replaces the tuple in an immutable fashion when written to.
*/
export const focusTupleAt: {
- (
+ (
self: Lens,
index: I,
): Lens
- (
+ (
index: I
): (self: Lens) => Lens
-} = Function.dual(2, (
+} = Function.dual(2, (
self: Lens,
index: I,
): Lens => map(
@@ -386,14 +386,14 @@ export const focusTupleAt: {
* Narrows the focus to an indexed element of a mutable tuple. Mutates the tuple in place when written to.
*/
export const focusMutableTupleAt: {
- (
+ (
self: Lens,
index: I,
): Lens
- (
+ (
index: I
): (self: Lens) => Lens
-} = Function.dual(2, (
+} = Function.dual(2, (
self: Lens,
index: I,
): Lens => map(
diff --git a/packages/effect-lens/src/Subscribable.ts b/packages/effect-lens/src/Subscribable.ts
index c88a108..10cf991 100644
--- a/packages/effect-lens/src/Subscribable.ts
+++ b/packages/effect-lens/src/Subscribable.ts
@@ -1,9 +1,44 @@
-import { Array, Chunk, Function, Subscribable } from "effect"
+import { Array, Chunk, Effect, Function, Option, Subscribable } from "effect"
import type { NoSuchElementException } from "effect/Cause"
export * from "effect/Subscribable"
+/**
+ * Maps over an `Option` value in the `Subscribable`.
+ */
+export const mapOption: {
+ (
+ self: Subscribable.Subscribable, E, R>,
+ f: (a: A) => B,
+ ): Subscribable.Subscribable, E, R>
+ (
+ f: (a: A) => B,
+ ): (self: Subscribable.Subscribable, E, R>) => Subscribable.Subscribable, E, R>
+} = Function.dual(2, (
+ self: Subscribable.Subscribable, E, R>,
+ f: (a: A) => B,
+): Subscribable.Subscribable, E, R> => Subscribable.map(self, Option.map(f)))
+
+/**
+ * Maps over an `Option` value in the `Subscribable` with an Effect.
+ */
+export const mapOptionEffect: {
+ (
+ self: Subscribable.Subscribable, E, R>,
+ f: (a: A) => Effect.Effect,
+ ): Subscribable.Subscribable, E | E2, R>
+ (
+ f: (a: A) => Effect.Effect,
+ ): (self: Subscribable.Subscribable, E, R>) => Subscribable.Subscribable, E | E2, R>
+} = Function.dual(2, (
+ self: Subscribable.Subscribable, E, R>,
+ f: (a: A) => Effect.Effect,
+): Subscribable.Subscribable, E | E2, R> => Subscribable.mapEffect(self, Option.match({
+ onSome: a => Effect.map(f(a), Option.some),
+ onNone: () => Effect.succeed(Option.none()),
+})))
+
/**
* Narrows the focus to a field of an object.
*/