{
  "id": "@typed/fx/Sink#loop",
  "canonicalId": "@typed/fx/Sink#loop",
  "symbol": {
    "id": "@typed/fx/Sink#loop",
    "packageName": "@typed/fx",
    "moduleName": "Sink",
    "exportName": "loop",
    "kind": "constant",
    "signatures": [
      "export declare const loop: {\n    <B, A, C>(seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): <E, R>(sink: Sink<C, E, R>) => Sink<A, E, R>;\n    <A, E, R, B, C>(sink: Sink<C, E, R>, seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): Sink<A, E, R>;\n};"
    ],
    "summary": "Threads pure state through successful inputs and forwards one derived value per input.",
    "sections": {
      "Why": "`loop` implements an ordered consumer-side state machine without exposing mutable state to the\nproducer.",
      "Ownership and lifetime": "Each adapted sink owns its seed. Updates are synchronous and follow callback invocation order;\nevery input produces exactly one downstream success. Failures bypass the state machine. Reusing\nthe same sink for another producer run continues from its retained seed; create a new sink to reset."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport * as Sink from \"@typed/fx/Sink\"\nconst totals = Sink.loop(Sink.make(Effect.logError, Effect.log), 0, (sum, n: number) => [sum + n, sum + n])"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Sink/combinators.ts",
      "line": 484
    },
    "since": "1.0.0",
    "category": "Stateful delivery"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Sink#loop",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": "Sink",
    "consumerSpecifier": "@typed/fx/Sink",
    "exportName": "loop",
    "qualifiedName": "loop",
    "declarationKey": "declaration:3929c14089929ef15a303970",
    "family": "variable",
    "signatures": [
      "export declare const loop: {\n    <B, A, C>(seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): <E, R>(sink: Sink<C, E, R>) => Sink<A, E, R>;\n    <A, E, R, B, C>(sink: Sink<C, E, R>, seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): Sink<A, E, R>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 484,
          "column": 14
        },
        "end": {
          "line": 502,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 485,
          "column": 3
        },
        "end": {
          "line": 488,
          "column": 51
        }
      },
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 489,
          "column": 3
        },
        "end": {
          "line": 493,
          "column": 20
        }
      }
    ],
    "aliases": [
      "@typed/fx#Sink.loop"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:3929c14089929ef15a303970",
    "name": "loop",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const loop: {\n    <B, A, C>(seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): <E, R>(sink: Sink<C, E, R>) => Sink<A, E, R>;\n    <A, E, R, B, C>(sink: Sink<C, E, R>, seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): Sink<A, E, R>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/combinators.ts",
            "start": {
              "line": 484,
              "column": 14
            },
            "end": {
              "line": 502,
              "column": 3
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "<B, A, C>(seed: B, f: (acc: B, a: A) => readonly [\n    C,\n    B\n]): <E, R>(sink: Sink<C, E, R>) => Sink<A, E, R>;",
          "<A, E, R, B, C>(sink: Sink<C, E, R>, seed: B, f: (acc: B, a: A) => readonly [\n    C,\n    B\n]): Sink<A, E, R>;"
        ],
        "typeParameters": [
          "B",
          "A",
          "C",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/combinators.ts",
            "start": {
              "line": 485,
              "column": 3
            },
            "end": {
              "line": 488,
              "column": 51
            }
          },
          {
            "file": "packages/fx/src/Sink/combinators.ts",
            "start": {
              "line": 489,
              "column": 3
            },
            "end": {
              "line": 493,
              "column": 20
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const loop: {\n    <B, A, C>(seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): <E, R>(sink: Sink<C, E, R>) => Sink<A, E, R>;\n    <A, E, R, B, C>(sink: Sink<C, E, R>, seed: B, f: (acc: B, a: A) => readonly [\n        C,\n        B\n    ]): Sink<A, E, R>;\n};"
    ],
    "typeParameters": [
      "B",
      "A",
      "C",
      "E",
      "R"
    ],
    "summary": "Threads pure state through successful inputs and forwards one derived value per input.",
    "sections": {
      "Why": "`loop` implements an ordered consumer-side state machine without exposing mutable state to the\nproducer.",
      "Ownership and lifetime": "Each adapted sink owns its seed. Updates are synchronous and follow callback invocation order;\nevery input produces exactly one downstream success. Failures bypass the state machine. Reusing\nthe same sink for another producer run continues from its retained seed; create a new sink to reset."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport * as Sink from \"@typed/fx/Sink\"\nconst totals = Sink.loop(Sink.make(Effect.logError, Effect.log), 0, (sum, n: number) => [sum + n, sum + n])"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 484,
          "column": 14
        },
        "end": {
          "line": 502,
          "column": 3
        }
      },
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 485,
          "column": 3
        },
        "end": {
          "line": 488,
          "column": 51
        }
      },
      {
        "file": "packages/fx/src/Sink/combinators.ts",
        "start": {
          "line": 489,
          "column": 3
        },
        "end": {
          "line": 493,
          "column": 20
        }
      }
    ],
    "since": "1.0.0",
    "category": "Stateful delivery"
  }
}
