{
  "id": "@typed/fx#Sink.reduce",
  "canonicalId": "@typed/fx/Sink#reduce",
  "symbol": {
    "id": "@typed/fx#Sink.reduce",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "Sink.reduce",
    "kind": "function",
    "signatures": [
      "export declare function reduce<A, B, E>(ref: Ref.Ref<B>, f: (b: B, a: A) => B): Sink<A, E, never>;"
    ],
    "summary": "Reduces values into a single result using a pure function. Pass a `Ref<B>`\n(e.g. from `Ref.make(initial)`); after running, read the result with `Ref.get(ref)`.",
    "sections": {
      "Why": "An existing Ref provides an explicit, independently readable result location for consumer-side\naggregation.",
      "Ownership and lifetime": "The caller owns the Ref. Each success returns a lazy atomic `Ref.update`; invoking `onSuccess`\ndoes not update immediately. If the producer executes callback Effects serially, values reduce in\nthat execution order. Concurrent execution is still atomic but may be scheduled in a different\norder than callback invocation. Failures are ignored and a thrown reducer exception is a defect."
    },
    "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.reduce(total, (sum, n: number) => sum + n)\n})"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Sink/combinators.ts",
      "line": 1709
    },
    "since": "1.0.0",
    "category": "Collecting values"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#Sink.reduce",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "Sink",
    "qualifiedName": "Sink.reduce",
    "declarationKey": "declaration:15aaa7e2c6b6c4b43ae6fde9",
    "family": "function",
    "signatures": [
      "export declare function reduce<A, B, E>(ref: Ref.Ref<B>, f: (b: B, a: A) => B): Sink<A, E, never>;"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 1709,
          "column": 1
        },
        "end": {
          "line": 1714,
          "column": 2
        }
      }
    ],
    "aliases": [
      "@typed/fx/Sink#reduce"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#Sink",
    "static": false,
    "importedFrom": "declaration:15aaa7e2c6b6c4b43ae6fde9"
  },
  "declaration": {
    "declarationKey": "declaration:15aaa7e2c6b6c4b43ae6fde9",
    "name": "reduce",
    "family": "function",
    "facets": [
      {
        "family": "function",
        "syntaxKind": "FunctionDeclaration",
        "signatures": [
          "export declare function reduce<A, B, E>(ref: Ref.Ref<B>, f: (b: B, a: A) => B): Sink<A, E, never>;"
        ],
        "typeParameters": [
          "A",
          "B",
          "E"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/combinators.ts",
            "start": {
              "line": 1709,
              "column": 1
            },
            "end": {
              "line": 1714,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare function reduce<A, B, E>(ref: Ref.Ref<B>, f: (b: B, a: A) => B): Sink<A, E, never>;"
    ],
    "typeParameters": [
      "A",
      "B",
      "E"
    ],
    "summary": "Reduces values into a single result using a pure function. Pass a `Ref<B>`\n(e.g. from `Ref.make(initial)`); after running, read the result with `Ref.get(ref)`.",
    "sections": {
      "Why": "An existing Ref provides an explicit, independently readable result location for consumer-side\naggregation.",
      "Ownership and lifetime": "The caller owns the Ref. Each success returns a lazy atomic `Ref.update`; invoking `onSuccess`\ndoes not update immediately. If the producer executes callback Effects serially, values reduce in\nthat execution order. Concurrent execution is still atomic but may be scheduled in a different\norder than callback invocation. Failures are ignored and a thrown reducer exception is a defect."
    },
    "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.reduce(total, (sum, n: number) => sum + n)\n})"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 1709,
          "column": 1
        },
        "end": {
          "line": 1714,
          "column": 2
        }
      }
    ],
    "since": "1.0.0",
    "category": "Collecting values"
  }
}
