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

add Array.ensure api #2812

Merged
merged 9 commits into from
Jun 18, 2024
Merged

Conversation

datner
Copy link
Member

@datner datner commented May 22, 2024

yum yum, I love getting garbage from my backend

  • test(Array): fix typos
  • chore: update readme to be more accurate
  • feat(Array): add cast

@datner datner requested a review from mikearnaldi as a code owner May 22, 2024 14:33
Copy link

changeset-bot bot commented May 22, 2024

🦋 Changeset detected

Latest commit: 707e99d

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

This PR includes changesets to release 25 packages
Name Type
effect Minor
@effect/cli 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-drizzle 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

@github-actions github-actions bot changed the base branch from main to next-minor May 22, 2024 14:33
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
packages/effect/dtslint/Array.ts Outdated Show resolved Hide resolved
packages/effect/src/Array.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot force-pushed the next-minor branch 2 times, most recently from dc79bd6 to 78f6d4a Compare May 22, 2024 19:06
@tim-smart tim-smart changed the title datner/array cast add Array.cast api May 22, 2024
@gcanti
Copy link
Contributor

gcanti commented May 23, 2024

How about using "ensure" instead of "cast"?
Shouldn't it take Iterable<A> as input like other APIs in the module?

@datner
Copy link
Member Author

datner commented May 23, 2024

@gcanti

How about using "ensure" instead of "cast"? Shouldn't it take Iterable<A> as input like other APIs in the module?

hmm ensure sounds like it would make sure that some condition is fulfilled, like every. I used cast because of castArray. Regarding Iterable I thought that accepting A | Iterable<A> would make the fromIterable util redundant, since it would be fromIterable + wrapping. What do you think?

@gcanti
Copy link
Contributor

gcanti commented May 23, 2024

it would make sure that some condition is fulfilled

Yes, the idea I've formed about the goal of this function is to "normalize" or "ensure" that you always have an array as output (which is the fulfilled condition)

the issue with Array<A> | A is that I cannot pass a readonly array

declare const readonlyNumbers: ReadonlyArray<number>;
const x = cast(readonlyNumbers); // error

@jessekelly881
Copy link
Contributor

jessekelly881 commented May 23, 2024

+1 A Schema transformation for this might be nice as well. :) Schema.CastArray(A) :: Schema<readonly A[], A | A[]>

@github-actions github-actions bot force-pushed the next-minor branch 13 times, most recently from a9f14be to badc78c Compare May 27, 2024 10:01
@tim-smart tim-smart merged commit 6e62d72 into Effect-TS:next-minor Jun 18, 2024
@github-actions github-actions bot mentioned this pull request Jun 18, 2024
github-actions bot pushed a commit that referenced this pull request Jun 19, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 19, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 19, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
tim-smart added a commit that referenced this pull request Jun 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
@datner datner deleted the datner/array-cast branch June 22, 2024 11:02
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