{
  "id": "@typed/fx/Sink#Sink.WithStateSemaphore",
  "canonicalId": "@typed/fx/Sink#Sink.WithStateSemaphore",
  "symbol": {
    "id": "@typed/fx/Sink#Sink.WithStateSemaphore",
    "packageName": "@typed/fx",
    "moduleName": "Sink",
    "exportName": "Sink.WithStateSemaphore",
    "kind": "interface",
    "signatures": [
      "interface WithStateSemaphore<A, E, R, B> extends WithEarlyExit<A, E, R> {\n    readonly modifyEffect: <C, E2, R2>(f: (state: B) => Effect<readonly [\n        C,\n        B\n    ], E2, R2>) => Effect<C, E | E2, R | R2>;\n    readonly updateEffect: <E2, R2>(f: (state: B) => Effect<B, E2, R2>) => Effect<B, E | E2, R | R2>;\n    readonly get: Effect<B, E, R>;\n}"
    ],
    "summary": "An early-exit sink with serialized effectful access to consumer-local state.",
    "sections": {
      "Why": "Effectful reducers may overlap; semaphore-guarded operations prevent lost updates while keeping\ntheir typed errors and service requirements visible.",
      "Ownership and lifetime": "`withStateSemaphore` owns the mutable cell and semaphore for one invocation. Each modify/update\nholds one permit until its effect completes or is interrupted, then releases it automatically.",
      "Property: get": "Reads the current state under the same semaphore as updates.",
      "Property: get: Why": "Locked reads cannot observe an in-progress effectful transition.",
      "Property: get: Ownership and lifetime": "The read holds one permit briefly and acquires no resource beyond the invocation-owned semaphore.",
      "Property: modifyEffect": "Atomically derives a result and replacement state under the sink's semaphore.",
      "Property: modifyEffect: Why": "Returning a separate result avoids a second unlocked read after an update.",
      "Property: modifyEffect: Ownership and lifetime": "One semaphore permit is held for the entire Effect and released on completion or interruption.\nThe state changes only when the Effect succeeds.",
      "Property: updateEffect": "Atomically replaces state and returns the replacement value.",
      "Property: updateEffect: Why": "It is the direct serialized form of an effectful state transition.",
      "Property: updateEffect: Ownership and lifetime": "One semaphore permit is held until the transition completes or is interrupted. Failure leaves\nthe state unchanged."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport type * as Sink from \"@typed/fx/Sink\"\nconst increment = (sink: Sink.Sink.WithStateSemaphore<number, never, never, number>) =>\n  sink.updateEffect((n) => Effect.succeed(n + 1))"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Sink/Sink.ts",
      "line": 418
    },
    "since": "1.0.0",
    "category": "Stateful delivery"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Sink#Sink.WithStateSemaphore",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.13",
    "moduleName": "Sink",
    "consumerSpecifier": "@typed/fx/Sink",
    "exportName": "Sink",
    "qualifiedName": "Sink.WithStateSemaphore",
    "declarationKey": "declaration:a5c9c9a4abf6538dfaf35bc9",
    "family": "interface",
    "signatures": [
      "interface WithStateSemaphore<A, E, R, B> extends WithEarlyExit<A, E, R> {\n    readonly modifyEffect: <C, E2, R2>(f: (state: B) => Effect<readonly [\n        C,\n        B\n    ], E2, R2>) => Effect<C, E | E2, R | R2>;\n    readonly updateEffect: <E2, R2>(f: (state: B) => Effect<B, E2, R2>) => Effect<B, E | E2, R | R2>;\n    readonly get: Effect<B, E, R>;\n}"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 418,
          "column": 3
        },
        "end": {
          "line": 469,
          "column": 4
        }
      },
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 468,
          "column": 5
        },
        "end": {
          "line": 468,
          "column": 35
        }
      },
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 433,
          "column": 5
        },
        "end": {
          "line": 435,
          "column": 36
        }
      },
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 451,
          "column": 5
        },
        "end": {
          "line": 453,
          "column": 36
        }
      }
    ],
    "aliases": [
      "@typed/fx#Sink.Sink.WithStateSemaphore"
    ],
    "isAlias": false,
    "parentId": "@typed/fx/Sink#Sink",
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:a5c9c9a4abf6538dfaf35bc9",
    "name": "WithStateSemaphore",
    "family": "interface",
    "facets": [
      {
        "family": "interface",
        "syntaxKind": "InterfaceDeclaration",
        "signatures": [
          "interface WithStateSemaphore<A, E, R, B> extends WithEarlyExit<A, E, R> {\n    readonly modifyEffect: <C, E2, R2>(f: (state: B) => Effect<readonly [\n        C,\n        B\n    ], E2, R2>) => Effect<C, E | E2, R | R2>;\n    readonly updateEffect: <E2, R2>(f: (state: B) => Effect<B, E2, R2>) => Effect<B, E | E2, R | R2>;\n    readonly get: Effect<B, E, R>;\n}"
        ],
        "typeParameters": [
          "A",
          "E",
          "R",
          "B"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/Sink.ts",
            "start": {
              "line": 418,
              "column": 3
            },
            "end": {
              "line": 469,
              "column": 4
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertySignature",
        "signatures": [
          "readonly get: Effect<B, E, R>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/Sink.ts",
            "start": {
              "line": 468,
              "column": 5
            },
            "end": {
              "line": 468,
              "column": 35
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertySignature",
        "signatures": [
          "readonly modifyEffect: <C, E2, R2>(f: (state: B) => Effect<readonly [\n    C,\n    B\n], E2, R2>) => Effect<C, E | E2, R | R2>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/Sink.ts",
            "start": {
              "line": 433,
              "column": 5
            },
            "end": {
              "line": 435,
              "column": 36
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      },
      {
        "family": "property",
        "syntaxKind": "PropertySignature",
        "signatures": [
          "readonly updateEffect: <E2, R2>(f: (state: B) => Effect<B, E2, R2>) => Effect<B, E | E2, R | R2>;"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Sink/Sink.ts",
            "start": {
              "line": 451,
              "column": 5
            },
            "end": {
              "line": 453,
              "column": 36
            }
          }
        ],
        "static": false,
        "readonly": true,
        "optional": false
      }
    ],
    "signatures": [
      "interface WithStateSemaphore<A, E, R, B> extends WithEarlyExit<A, E, R> {\n    readonly modifyEffect: <C, E2, R2>(f: (state: B) => Effect<readonly [\n        C,\n        B\n    ], E2, R2>) => Effect<C, E | E2, R | R2>;\n    readonly updateEffect: <E2, R2>(f: (state: B) => Effect<B, E2, R2>) => Effect<B, E | E2, R | R2>;\n    readonly get: Effect<B, E, R>;\n}"
    ],
    "typeParameters": [
      "A",
      "E",
      "R",
      "B"
    ],
    "summary": "An early-exit sink with serialized effectful access to consumer-local state.",
    "sections": {
      "Why": "Effectful reducers may overlap; semaphore-guarded operations prevent lost updates while keeping\ntheir typed errors and service requirements visible.",
      "Ownership and lifetime": "`withStateSemaphore` owns the mutable cell and semaphore for one invocation. Each modify/update\nholds one permit until its effect completes or is interrupted, then releases it automatically.",
      "Property: get": "Reads the current state under the same semaphore as updates.",
      "Property: get: Why": "Locked reads cannot observe an in-progress effectful transition.",
      "Property: get: Ownership and lifetime": "The read holds one permit briefly and acquires no resource beyond the invocation-owned semaphore.",
      "Property: modifyEffect": "Atomically derives a result and replacement state under the sink's semaphore.",
      "Property: modifyEffect: Why": "Returning a separate result avoids a second unlocked read after an update.",
      "Property: modifyEffect: Ownership and lifetime": "One semaphore permit is held for the entire Effect and released on completion or interruption.\nThe state changes only when the Effect succeeds.",
      "Property: updateEffect": "Atomically replaces state and returns the replacement value.",
      "Property: updateEffect: Why": "It is the direct serialized form of an effectful state transition.",
      "Property: updateEffect: Ownership and lifetime": "One semaphore permit is held until the transition completes or is interrupted. Failure leaves\nthe state unchanged."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Effect } from \"effect\"\nimport type * as Sink from \"@typed/fx/Sink\"\nconst increment = (sink: Sink.Sink.WithStateSemaphore<number, never, never, number>) =>\n  sink.updateEffect((n) => Effect.succeed(n + 1))"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 418,
          "column": 3
        },
        "end": {
          "line": 469,
          "column": 4
        }
      },
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 468,
          "column": 5
        },
        "end": {
          "line": 468,
          "column": 35
        }
      },
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 433,
          "column": 5
        },
        "end": {
          "line": 435,
          "column": 36
        }
      },
      {
        "file": "packages/fx/src/Sink/Sink.ts",
        "start": {
          "line": 451,
          "column": 5
        },
        "end": {
          "line": 453,
          "column": 36
        }
      }
    ],
    "since": "1.0.0",
    "category": "Stateful delivery"
  }
}
