{
  "id": "@typed/fx/Sink#reduceEffect",
  "canonicalId": "@typed/fx/Sink#reduceEffect",
  "symbol": {
    "id": "@typed/fx/Sink#reduceEffect",
    "packageName": "@typed/fx",
    "moduleName": "Sink",
    "exportName": "reduceEffect",
    "kind": "function",
    "signatures": [
      "export declare function reduceEffect<A, B, E, E2, R2>(ref: Ref.Ref<B>, f: (b: B, a: A) => Effect.Effect<B, E2, R2>): Sink<A, E | E2, R2>;"
    ],
    "summary": "Reduces values into a single result using an effectful function. Pass a `Ref<B>`;\nafter running, read the result with `Ref.get(ref)`. If the reducer effect fails,\nthe ref is left unchanged (Sink onSuccess is typed as never failing).",
    "sections": {
      "Why": "Aggregation may require Effect services or asynchronous work while the result remains explicitly\navailable through a caller-owned Ref.",
      "Ownership and lifetime": "The caller owns the Ref. Each success returns a lazy read/reduce/write Effect; invocation alone does\nno work. The three steps are not one atomic operation. Serialized producers preserve execution\norder, while overlapping executions can read the same value and commit in completion order.\nReducer failures, producer failures, and interrupted writes are ignored. Use\n`withStateSemaphore` when the whole effectful transition must be serialized."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Ref } from \"effect\"\nimport * as Sink from \"@typed/fx/Sink\"\nconst program = Effect.gen(function* () {\n  const total = yield* Ref.make(0)\n  return Sink.reduceEffect(total, (sum, n: number) => Effect.succeed(sum + n))\n})"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Sink/combinators.ts",
      "line": 1746
    },
    "since": "1.0.0",
    "category": "Collecting values"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Sink#reduceEffect",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": "Sink",
    "consumerSpecifier": "@typed/fx/Sink",
    "exportName": "reduceEffect",
    "qualifiedName": "reduceEffect",
    "declarationKey": "declaration:2859fe1e0ba6821532a127de",
    "family": "function",
    "signatures": [
      "export declare function reduceEffect<A, B, E, E2, R2>(ref: Ref.Ref<B>, f: (b: B, a: A) => Effect.Effect<B, E2, R2>): Sink<A, E | E2, R2>;"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 1746,
          "column": 1
        },
        "end": {
          "line": 1760,
          "column": 2
        }
      }
    ],
    "aliases": [
      "@typed/fx#Sink.reduceEffect"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:2859fe1e0ba6821532a127de",
    "name": "reduceEffect",
    "family": "function",
    "facets": [
      {
        "family": "function",
        "syntaxKind": "FunctionDeclaration",
        "signatures": [
          "export declare function reduceEffect<A, B, E, E2, R2>(ref: Ref.Ref<B>, f: (b: B, a: A) => Effect.Effect<B, E2, R2>): Sink<A, E | E2, R2>;"
        ],
        "typeParameters": [
          "A",
          "B",
          "E",
          "E2",
          "R2"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/combinators.ts",
            "start": {
              "line": 1746,
              "column": 1
            },
            "end": {
              "line": 1760,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare function reduceEffect<A, B, E, E2, R2>(ref: Ref.Ref<B>, f: (b: B, a: A) => Effect.Effect<B, E2, R2>): Sink<A, E | E2, R2>;"
    ],
    "typeParameters": [
      "A",
      "B",
      "E",
      "E2",
      "R2"
    ],
    "summary": "Reduces values into a single result using an effectful function. Pass a `Ref<B>`;\nafter running, read the result with `Ref.get(ref)`. If the reducer effect fails,\nthe ref is left unchanged (Sink onSuccess is typed as never failing).",
    "sections": {
      "Why": "Aggregation may require Effect services or asynchronous work while the result remains explicitly\navailable through a caller-owned Ref.",
      "Ownership and lifetime": "The caller owns the Ref. Each success returns a lazy read/reduce/write Effect; invocation alone does\nno work. The three steps are not one atomic operation. Serialized producers preserve execution\norder, while overlapping executions can read the same value and commit in completion order.\nReducer failures, producer failures, and interrupted writes are ignored. Use\n`withStateSemaphore` when the whole effectful transition must be serialized."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect, Ref } from \"effect\"\nimport * as Sink from \"@typed/fx/Sink\"\nconst program = Effect.gen(function* () {\n  const total = yield* Ref.make(0)\n  return Sink.reduceEffect(total, (sum, n: number) => Effect.succeed(sum + n))\n})"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 1746,
          "column": 1
        },
        "end": {
          "line": 1760,
          "column": 2
        }
      }
    ],
    "since": "1.0.0",
    "category": "Collecting values"
  }
}
