Skip to content
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

Introduce bindAll #3486

Merged
merged 8 commits into from
Aug 29, 2024
Merged

Introduce bindAll #3486

merged 8 commits into from
Aug 29, 2024

Conversation

KhraksMamtsov
Copy link
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Related

Copy link

changeset-bot bot commented Aug 19, 2024

🦋 Changeset detected

Latest commit: 817f169

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

This PR includes changesets to release 31 packages
Name Type
effect Minor
@effect/cli Major
@effect/cluster-browser Major
@effect/cluster-node Major
@effect/cluster-workflow 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-http Major
@effect/rpc Major
@effect/schema Major
@effect/sql-d1 Major
@effect/sql-drizzle Major
@effect/sql-kysely Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun 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

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

@gcanti
Copy link
Contributor

gcanti commented Aug 19, 2024

is bindAll truly necessary when nesting can achieve pretty much the same result without introducing new APIs?

Effect.Do.pipe(
  Effect.bind("x", () => Effect.succeed(2)),
  Effect.bind("y", ({ x }) =>
    Effect.all({
      a: Effect.succeed(x),
      b: Effect.succeed("ops")
    }, { mode: "either" }))
)

vs

Effect.Do.pipe(
  Effect.bind("x", () => Effect.succeed(2)),
  Effect.bindAll(({ x }) => ({
    a: Effect.succeed(x),
    b: Effect.succeed("ops")
  }), { mode: "either" })
)

@tim-smart
Copy link
Member

is bindAll truly necessary when nesting can achieve pretty much the same result without introducing new APIs?

With Effect.all you will need to follow that up with merging y into the result. So the equivalent would be:

Effect.Do.pipe(
  Effect.bind("x", () => Effect.succeed(2)),
  Effect.flatMap((value) =>
    Effect.all(
      {
        a: Effect.succeed(value.x),
        b: Effect.succeed("ops"),
      },
      { concurrency: "unbounded" },
    ).pipe(Effect.map((result) => ({ ...value, ...result }))),
  ),
)

@KhraksMamtsov
Copy link
Contributor Author

On the one hand, I agree with Guilio. On the other hand, I saw that Michael approved of the idea. I had time to contribute to the effect and practice with the types)

packages/effect/src/Effect.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot force-pushed the next-minor branch 8 times, most recently from 59d9522 to 9d8acac Compare August 27, 2024 22:27
@KhraksMamtsov
Copy link
Contributor Author

@tim-smart, please confirm that everything is fine

@tim-smart
Copy link
Member

/rebase

packages/effect/src/Effect.ts Outdated Show resolved Hide resolved
packages/effect/src/Effect.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot force-pushed the next-minor branch 2 times, most recently from 6f12b7a to 9ea0f4f Compare August 29, 2024 02:10
@tim-smart
Copy link
Member

/rebase

@tim-smart tim-smart merged commit 0045357 into Effect-TS:next-minor Aug 29, 2024
11 checks passed
@github-actions github-actions bot mentioned this pull request Aug 29, 2024
github-actions bot pushed a commit that referenced this pull request Aug 30, 2024
Co-authored-by: maksim.khramtsov <maksim.khramtsov@btsdigital.kz>
Co-authored-by: Tim <hello@timsmart.co>
tim-smart added a commit that referenced this pull request Aug 30, 2024
Co-authored-by: maksim.khramtsov <maksim.khramtsov@btsdigital.kz>
Co-authored-by: Tim <hello@timsmart.co>
@KhraksMamtsov KhraksMamtsov deleted the bind-all branch September 25, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants