Skip to content

Conversation

@mikearnaldi
Copy link
Member

@mikearnaldi mikearnaldi commented Jul 30, 2025

Introduce ReadonlyTag as the covariant side of a tag, enables:

import type { Context } from "effect"
import { Effect } from "effect"

export class MyRequirement extends Effect.Service<MyRequirement>()(
  "MyRequirement",
  { succeed: () => 42 }
) {}

export class MyUseCase extends Effect.Service<MyUseCase>()("MyUseCase", {
  dependencies: [MyRequirement.Default],
  effect: Effect.gen(function* () {
    const requirement = yield* MyRequirement
    return Effect.fn("MyUseCase.execute")(function* () {
      return requirement()
    })
  })
}) {}

export function effectHandler<I, Args extends Array<any>, A, E, R>(
  service: Context.ReadonlyTag<I, (...args: Args) => Effect.Effect<A, E, R>>
) {
  return Effect.fn("effectHandler")(function* (...args: Args) {
    const execute = yield* service
    yield* execute(...args)
  })
}

export const program = effectHandler(MyUseCase)

Discord discussion: https://discord.com/channels/795981131316985866/795983589644304396/1400218469160714261

@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Jul 30, 2025
@changeset-bot
Copy link

changeset-bot bot commented Jul 30, 2025

🦋 Changeset detected

Latest commit: f65f14c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
effect Minor
@effect/cli Major
@effect/cluster Major
@effect/experimental Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/platform Major
@effect/printer-ansi Major
@effect/printer Major
@effect/rpc Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-drizzle Major
@effect/sql-kysely Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/sql Major
@effect/typeclass Major
@effect/vitest Major
@effect/workflow Major
@effect/ai Major
@effect/ai-amazon-bedrock Major
@effect/ai-anthropic Major
@effect/ai-google Major
@effect/ai-openai Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mikearnaldi mikearnaldi requested a review from tim-smart July 31, 2025 15:52
@effect-bot effect-bot changed the base branch from main to next-minor August 2, 2025 14:43
@mikearnaldi mikearnaldi merged commit 9370cc0 into next-minor Aug 2, 2025
11 checks passed
@mikearnaldi mikearnaldi deleted the feat/readonly-tag branch August 2, 2025 15:34
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Aug 2, 2025
@effect-bot effect-bot mentioned this pull request Aug 2, 2025
effect-bot pushed a commit that referenced this pull request Aug 3, 2025
effect-bot pushed a commit that referenced this pull request Aug 3, 2025
effect-bot pushed a commit that referenced this pull request Aug 3, 2025
effect-bot pushed a commit that referenced this pull request Aug 4, 2025
effect-bot pushed a commit that referenced this pull request Aug 6, 2025
effect-bot pushed a commit that referenced this pull request Aug 6, 2025
effect-bot pushed a commit that referenced this pull request Aug 6, 2025
effect-bot pushed a commit that referenced this pull request Aug 6, 2025
effect-bot pushed a commit that referenced this pull request Aug 6, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Aug 8, 2025
effect-bot pushed a commit that referenced this pull request Sep 6, 2025
effect-bot pushed a commit that referenced this pull request Sep 6, 2025
effect-bot pushed a commit that referenced this pull request Sep 6, 2025
effect-bot pushed a commit that referenced this pull request Sep 7, 2025
effect-bot pushed a commit that referenced this pull request Sep 7, 2025
effect-bot pushed a commit that referenced this pull request Sep 8, 2025
effect-bot pushed a commit that referenced this pull request Sep 9, 2025
effect-bot pushed a commit that referenced this pull request Sep 9, 2025
effect-bot pushed a commit that referenced this pull request Sep 9, 2025
effect-bot pushed a commit that referenced this pull request Sep 9, 2025
effect-bot pushed a commit that referenced this pull request Sep 10, 2025
effect-bot pushed a commit that referenced this pull request Sep 10, 2025
effect-bot pushed a commit that referenced this pull request Sep 10, 2025
effect-bot pushed a commit that referenced this pull request Sep 10, 2025
effect-bot pushed a commit that referenced this pull request Sep 11, 2025
effect-bot pushed a commit that referenced this pull request Sep 11, 2025
effect-bot pushed a commit that referenced this pull request Sep 13, 2025
effect-bot pushed a commit that referenced this pull request Sep 13, 2025
patroza pushed a commit to patroza/effect that referenced this pull request Sep 13, 2025
effect-bot pushed a commit that referenced this pull request Sep 15, 2025
effect-bot pushed a commit that referenced this pull request Sep 15, 2025
effect-bot pushed a commit that referenced this pull request Sep 15, 2025
effect-bot pushed a commit that referenced this pull request Sep 15, 2025
effect-bot pushed a commit that referenced this pull request Sep 16, 2025
effect-bot pushed a commit that referenced this pull request Sep 16, 2025
effect-bot pushed a commit that referenced this pull request Sep 17, 2025
effect-bot pushed a commit that referenced this pull request Sep 17, 2025
patroza pushed a commit to patroza/effect that referenced this pull request Sep 17, 2025
tim-smart pushed a commit that referenced this pull request Sep 30, 2025
tim-smart pushed a commit that referenced this pull request Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants