effect-resources-scope

Resource Management (Scope)

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "effect-resources-scope" with this command: npx skills add mepuka/effect-ontology/mepuka-effect-ontology-effect-resources-scope

Resource Management (Scope)

Acquire/Release

const withConn = Effect.acquireRelease( Effect.sync(() => open()), (conn) => Effect.sync(() => close(conn)) ).pipe(Effect.flatMap(use))

Scoped

yield* Effect.scoped( Effect.gen(function* () { const h = yield* Effect.acquireRelease(acquire(), release) return yield* use(h) }) )

Finalizers

yield* Effect.addFinalizer(() => cleanup)

Ensuring

operation.pipe(Effect.ensuring(cleanup))

Real-world snippet: wrap Promise APIs with typed errors and spans

const wrapS3Promise = <T>(promise: Promise<T> | Effect.Effect<Promise<T>>) => Effect.gen(function* () { if (promise instanceof Promise) { return yield* Effect.tryPromise({ try: () => promise, catch: (cause) => new S3Error({ cause }) }) } return yield* promise.pipe( Effect.flatMap((cb) => Effect.tryPromise({ try: () => cb, catch: (cause) => new S3Error({ cause }) }) ) ) }).pipe(Effect.catchTag("UnknownException", (cause) => new S3Error({ cause })))

// Usage with spans const put = wrapS3Promise(client.send(new S3.PutObjectCommand(args))).pipe( Effect.withSpan("S3.putObject", { attributes: { key: args.Key } }) )

Local Source Reference

CRITICAL: Search local Effect source before implementing

The full Effect source code is available at docs/effect-source/ . Always search the actual implementation before writing Effect code.

Key Source Files

  • Effect: docs/effect-source/effect/src/Effect.ts

  • Scope: docs/effect-source/effect/src/Scope.ts

Example Searches

Find acquireRelease patterns

grep -F "acquireRelease" docs/effect-source/effect/src/Effect.ts

Study scoped operations

grep -F "scoped" docs/effect-source/effect/src/Effect.ts grep -F "addFinalizer" docs/effect-source/effect/src/Effect.ts

Find ensuring patterns

grep -F "ensuring" docs/effect-source/effect/src/Effect.ts

Look at Scope implementation

grep -F "export" docs/effect-source/effect/src/Scope.ts | grep -F "function"

Workflow

  • Identify the resource management API you need (e.g., acquireRelease)

  • Search docs/effect-source/effect/src/Effect.ts for the implementation

  • Study the types and resource patterns

  • Look at test files for usage examples

  • Write your code based on real implementations

Real source code > documentation > assumptions

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

effect-index

No summary provided by upstream source.

Repository SourceNeeds Review
299-mepuka
General

effect-patterns-hub

No summary provided by upstream source.

Repository SourceNeeds Review
General

effect-errors-retries

No summary provided by upstream source.

Repository SourceNeeds Review
General

effect-concurrency-fibers

No summary provided by upstream source.

Repository SourceNeeds Review