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

make Array.separate, Array.getRights, Array.getLefts, Array.getSomes heterogeneous #2744

Merged
merged 10 commits into from
May 23, 2024

Conversation

KhraksMamtsov
Copy link
Contributor

Type

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

Description

Related

  • Related Issue #
  • Closes #

Copy link

changeset-bot bot commented May 14, 2024

🦋 Changeset detected

Latest commit: 91bcf99

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

This PR includes changesets to release 24 packages
Name Type
effect Patch
@effect/cli Patch
@effect/experimental Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/platform Patch
@effect/printer-ansi Patch
@effect/printer Patch
@effect/rpc-http Patch
@effect/rpc Patch
@effect/schema Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/sql Patch
@effect/typeclass Patch
@effect/vitest 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

@tim-smart tim-smart requested a review from gcanti May 23, 2024 00:02
Copy link
Contributor

@gcanti gcanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified the signatures (#2823) and added a few dtslint tests (#2825).

I would extend the same support to:

  • getRights
  • getLefts
  • getSomes

Additionally, I would add the following dtslint tests (also for the other 3) to showcase the new capabilities:

// $ExpectType [(string | Date)[], (number | boolean)[]]
Array.separate(hole<Iterable<Either.Either<number, string> | Either.Either<boolean, Date>>>())

// $ExpectType [(string | Date)[], (number | boolean)[]]
Array.separate(hole<Iterable<Either.Either<number, string>> | Iterable<Either.Either<boolean, Date>>>())

@KhraksMamtsov KhraksMamtsov changed the title make Array.separate heterogeneous make Array.separate, Array.getRights, Array.getLefts, Array.getSomes heterogeneous May 23, 2024
@@ -2254,7 +2254,14 @@ export const partitionMap: {
* @category filtering
* @since 2.0.0
*/
export const getSomes: <A>(self: Iterable<Option<A>>) => Array<A> = filterMap(identity)

export const getSomes: <
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work as well?

export const getSomes: <T extends Iterable<Option<X>>, X = any>(
  self: T
) => Array<Option.Value<ReadonlyArray.Infer<T>>> = filterMap(identity as any)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@gcanti gcanti merged commit a44e532 into Effect-TS:main May 23, 2024
12 checks passed
@gcanti
Copy link
Contributor

gcanti commented May 23, 2024

@KhraksMamtsov thanks!

@github-actions github-actions bot mentioned this pull request May 23, 2024
@KhraksMamtsov KhraksMamtsov deleted the array-separate branch May 23, 2024 17:14
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.

None yet

2 participants