Skip to content

Add Stream.filterMapEffectOption combinator #4265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: next-minor
Choose a base branch
from

Conversation

lucas-barake
Copy link

Type

  • Feature

Description

Added Stream.filterMapEffectOption combinator for effectful filtering and mapping in a single step. This utility combines filtering and mapping operations with effects into a single operation that returns an Option, improving ergonomics when you need to conditionally transform stream elements with effects.

Example usage:

Stream.make(1, 2, 3, 4).pipe(
  Stream.filterMapEffectOption((n) =>
    Effect.succeed(
      n % 2 === 0 ? Option.some(n * 2) : Option.none()
    )
  )
)
// Results in: Stream(4, 8)

Notes

  • I've left the @since tag version empty as I'm not sure which version to use. Would appreciate guidance on this.
  • This feature was requested in this Discord discussion

Related

  • Related Issue # N/A
  • Closes # N/A

Copy link

changeset-bot bot commented Jan 15, 2025

🦋 Changeset detected

Latest commit: f17d13c

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

This PR includes changesets to release 32 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/ai Major
@effect/ai-anthropic 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

@effect-bot effect-bot force-pushed the next-minor branch 28 times, most recently from 9ebc36c to a192a9c Compare January 22, 2025 13:53
@effect-bot effect-bot force-pushed the next-minor branch 18 times, most recently from e7df45d to a3f9aa2 Compare April 29, 2025 07:37
@effect-bot effect-bot force-pushed the next-minor branch 12 times, most recently from 768a4f2 to 7f658a7 Compare May 2, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Discussion Ongoing
Development

Successfully merging this pull request may close these issues.

4 participants