Skip to content

Pass Match.fn arguments to record and discriminator handlers - #10876

Open
jasonkuhrt wants to merge 4 commits into
Effect-TS:mainfrom
jasonkuhrt:match-fn-record-combinator-arguments
Open

jasonkuhrt wants to merge 4 commits into
Effect-TS:mainfrom
jasonkuhrt:match-fn-record-combinator-arguments

Conversation

@jasonkuhrt

@jasonkuhrt jasonkuhrt commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Written by an AI agent (Amp) on behalf of @jasonkuhrt.

Closes #10874

Builds on #10875. Its first three commits are #10875's: without that fix, these combinators would also give Match.type handlers the input twice. The change here is the last commit.

The record and discriminator combinators now carry a matcher's Args the way Match.tag does, so a Match.fn matcher can use them. The combinators are tags, tagsExhaustive, tagStartsWith, discriminator, discriminatorStartsWith, discriminators, discriminatorsExhaustive, literals and literalsExhaustive.

  • Each handler is typed (_: Narrowed, ...args: Args) => Ret, self is Matcher<…, Ret, Args>, and the result keeps Args.
  • On a Match.fn matcher, tagsExhaustive, discriminatorsExhaustive and literalsExhaustive return (...args: Args) => …, as exhaustive does.
  • At run time, discriminators and literals pass the arguments to the handler. discriminator already did. typeTags and valueTags keep their single-argument handlers because Pass Match.type handlers the matched input alone #10875 builds them with Match.type(), whose matcher doesn't forward arguments.

Match.type and Match.value matchers keep Args = [], so their signatures don't change.

Verification

@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 46ea7dc

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

This PR includes changesets to release 40 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

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

@effect-janitor effect-janitor Bot added the 4.0 label Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.17 KB 40.17 KB 0.00 KB (0.00%)
basic.ts 7.31 KB 7.31 KB 0.00 KB (0.00%)
batching.ts 11.29 KB 11.29 KB 0.00 KB (0.00%)
brand.ts 7.05 KB 7.05 KB 0.00 KB (0.00%)
cache.ts 11.75 KB 11.75 KB 0.00 KB (0.00%)
config.ts 23.18 KB 23.18 KB 0.00 KB (0.00%)
differ.ts 22.30 KB 22.30 KB 0.00 KB (0.00%)
http-client.ts 27.87 KB 27.87 KB 0.00 KB (0.00%)
http-router.ts 38.66 KB 38.66 KB 0.00 KB (0.00%)
logger.ts 12.19 KB 12.19 KB 0.00 KB (0.00%)
metric.ts 9.66 KB 9.66 KB 0.00 KB (0.00%)
optic.ts 7.28 KB 7.28 KB 0.00 KB (0.00%)
pubsub.ts 16.23 KB 16.23 KB 0.00 KB (0.00%)
queue.ts 13.13 KB 13.13 KB 0.00 KB (0.00%)
schedule.ts 11.99 KB 11.99 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.36 KB 14.36 KB 0.00 KB (0.00%)
schema-binary.ts 42.92 KB 42.92 KB 0.00 KB (0.00%)
schema-class.ts 22.01 KB 22.01 KB 0.00 KB (0.00%)
schema-codegen.ts 30.78 KB 30.78 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.64 KB 30.64 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.33 KB 28.33 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.61 KB 15.61 KB 0.00 KB (0.00%)
schema-string.ts 12.56 KB 12.56 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.50 KB 16.50 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.72 KB 39.72 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.20 KB 21.20 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.36 KB 21.36 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.45 KB 21.45 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.50 KB 26.50 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.54 KB 21.54 KB 0.00 KB (0.00%)
schema.ts 21.14 KB 21.14 KB 0.00 KB (0.00%)
stm.ts 14.48 KB 14.48 KB 0.00 KB (0.00%)
stream.ts 10.61 KB 10.61 KB 0.00 KB (0.00%)

@jasonkuhrt

Copy link
Copy Markdown
Contributor Author

Written by an AI agent (Amp) on behalf of @jasonkuhrt.

Rebuilt on #10875's new head (67bd37a), so this PR now starts with your three commits there and adds one commit.

This branch is waiting to be deployed

1 waiting deployment
fork — 46ea7dc1 Waiting Nov 24, 2026 by jasonkuhrt via approval-gate #27232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Match.tagsExhaustive and other record combinators reject a Match.fn matcher and drop its arguments

3 participants