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

Release queue: minor #3410

Merged
merged 12 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-toys-share.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
"effect": patch
---

add `Micro.isMicroCause` guard
5 changes: 5 additions & 0 deletions .changeset/curvy-cats-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
"effect": minor
---

preserve `Array.modify` `Array.modifyOption` non emptiness
10 changes: 10 additions & 0 deletions .changeset/curvy-clouds-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 1,10 @@
---
"@effect/platform": patch
---

add HttpApi modules

The `HttpApi` family of modules provide a declarative way to define HTTP APIs.

For more infomation see the README.md for the /platform package:<br />
https://github.com/Effect-TS/effect/blob/main/packages/platform/README.md
5 changes: 5 additions & 0 deletions .changeset/dry-badgers-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
"effect": minor
---

improve: type Fiber.awaitAll as Exit<A, E>[].
5 changes: 5 additions & 0 deletions .changeset/hot-dogs-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
"effect": minor
---

New constructor Config.nonEmptyString
5 changes: 5 additions & 0 deletions .changeset/rich-pumas-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
"effect": minor
---

preserve `Array.replace` `Array.replaceOption` non emptiness
29 changes: 29 additions & 0 deletions .changeset/shiny-carpets-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 1,29 @@
---
"effect": minor
---

add `Effect.bindAll` api

This api allows you to combine `Effect.all` with `Effect.bind`. It is useful
when you want to concurrently run multiple effects and then combine their
results in a Do notation pipeline.

```ts
import { Effect } from "effect";

const result = Effect.Do.pipe(
Effect.bind("x", () => Effect.succeed(2)),
Effect.bindAll(
({ x }) => ({
a: Effect.succeed(x 1),
b: Effect.succeed("foo"),
}),
{ concurrency: 2 },
),
);
assert.deepStrictEqual(Effect.runSync(result), {
x: 2,
a: 3,
b: "foo",
});
```
7 changes: 7 additions & 0 deletions .changeset/short-garlics-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 1,7 @@
---
"effect": minor
---

add `propagateInterruption` option to Fiber{Handle,Set,Map}

This option will send any external interrupts to the .join result.
25 changes: 25 additions & 0 deletions .changeset/stream-race.md
Original file line number Diff line number Diff line change
@@ -0,0 1,25 @@
---
"effect": minor
---


feat(Stream): implement `race` operator, which accepts two upstreams and returns a stream that mirrors the first upstream to emit an item and interrupts the other upstream.

```ts
import { Stream, Schedule, Console, Effect } from "effect"

const stream = Stream.fromSchedule(Schedule.spaced('2 millis')).pipe(
Stream.race(Stream.fromSchedule(Schedule.spaced('1 millis'))),
Stream.take(6),
Stream.tap(n => Console.log(n))
)

Effect.runPromise(Stream.runDrain(stream))
// Output each millisecond from the first stream, the rest streams are interrupted
// 0
// 1
// 2
// 3
// 4
// 5
```
5 changes: 5 additions & 0 deletions .changeset/witty-kings-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
"effect": minor
---

Avoid automatic propagation of finalizer concurrency, closes #3440
5 changes: 5 additions & 0 deletions .changeset/young-pugs-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
"effect": minor
---

add Context.getOrElse api, for gettings a Tag's value with a fallback
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
{
"semi": false,
"trailingComma": "none"
}
170 changes: 170 additions & 0 deletions packages/effect/dtslint/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1334,3 1334,173 @@ Array.getSomes(hole<Iterable<Option.Option<number> | Option.Option<string>>>())

// $ExpectType (string | number)[]
Array.getSomes(hole<Iterable<Option.Option<number>> | Iterable<Option.Option<string>>>())

// -------------------------------------------------------------------------------------
// replace
// -------------------------------------------------------------------------------------

// $ExpectType string[]
Array.replace([], 0, "a")

// $ExpectType (string | number)[]
Array.replace(numbers, 0, "a")

// $ExpectType [number | "a", ...(number | "a")[]]
Array.replace(nonEmptyNumbers, 0, "a" as const)

// $ExpectType ("a" | 1 | 2)[]
Array.replace(new Set([1, 2] as const), 0, "a" as const)

// $ExpectType string[]
pipe([], Array.replace(0, "a"))

// $ExpectType (string | number)[]
pipe(numbers, Array.replace(0, "a"))

// $ExpectType [number | "a", ...(number | "a")[]]
pipe(nonEmptyNumbers, Array.replace(0, "a" as const))

// $ExpectType ("a" | 1 | 2)[]
pipe(new Set([1, 2] as const), Array.replace(0, "a" as const))

// $ExpectType [number | "a", ...(number | "a")[]]
pipe(Array.of(1), Array.replace(0, "a" as const))

// -------------------------------------------------------------------------------------
// replaceOption
// -------------------------------------------------------------------------------------

// $ExpectType Option<string[]>
Array.replaceOption([], 0, "a")

// $ExpectType Option<(string | number)[]>
Array.replaceOption(numbers, 0, "a")

// $ExpectType Option<[number | "a", ...(number | "a")[]]>
Array.replaceOption(nonEmptyNumbers, 0, "a" as const)

// $ExpectType Option<("a" | 1 | 2)[]>
Array.replaceOption(new Set([1, 2] as const), 0, "a" as const)

// $ExpectType Option<string[]>
pipe([], Array.replaceOption(0, "a"))

// $ExpectType Option<(string | number)[]>
pipe(numbers, Array.replaceOption(0, "a"))

// $ExpectType Option<[number | "a", ...(number | "a")[]]>
pipe(nonEmptyNumbers, Array.replaceOption(0, "a" as const))

// $ExpectType Option<("a" | 1 | 2)[]>
pipe(new Set([1, 2] as const), Array.replaceOption(0, "a" as const))

// -------------------------------------------------------------------------------------
// modify
// -------------------------------------------------------------------------------------

// $ExpectType string[]
Array.modify([], 0, (
_n // $ExpectType never
) => "a")
// $ExpectType (string | number)[]
Array.modify(numbers, 0, (
_n // $ExpectType number
) => "a")

// $ExpectType [number | "a", ...(number | "a")[]]
Array.modify(nonEmptyNumbers, 0, (
_n // $ExpectType number
) => "a" as const)

// $ExpectType ("a" | 1 | 2)[]
Array.modify(new Set([1, 2] as const), 0, (
_n // $ExpectType 1 | 2
) => "a" as const)

// $ExpectType string[]
pipe(
[],
Array.modify(0, (
_n // $ExpectType never
) => "a")
)

// $ExpectType (string | number)[]
pipe(
numbers,
Array.modify(0, (
_n // $ExpectType number
) => "a")
)

// $ExpectType [number | "a", ...(number | "a")[]]
pipe(
nonEmptyNumbers,
Array.modify(0, (
_n // $ExpectType number
) => "a" as const)
)

// $ExpectType ("a" | 1 | 2)[]
pipe(
new Set([1, 2] as const),
Array.modify(0, (
_n // $ExpectType 1 | 2
) => "a" as const)
)

// -------------------------------------------------------------------------------------
// modifyOption
// -------------------------------------------------------------------------------------

// $ExpectType Option<string[]>
Array.modifyOption([], 0, (
_n // $ExpectType never
) => "a")

// $ExpectType Option<(string | number)[]>
Array.modifyOption(numbers, 0, (
_n // $ExpectType number
) => "a")

// $ExpectType Option<[number | "a", ...(number | "a")[]]>
Array.modifyOption(nonEmptyNumbers, 0, (
_n // $ExpectType number
) => "a" as const)

// $ExpectType Option<("a" | 1 | 2)[]>
Array.modifyOption(new Set([1, 2] as const), 0, (
_n // $ExpectType 1 | 2
) => "a" as const)

// $ExpectType Option<string[]>
pipe(
[],
Array.modifyOption(0, (
_n // $ExpectType never
) => "a")
)

// $ExpectType Option<(string | number)[]>
pipe(
numbers,
Array.modifyOption(0, (
_n // $ExpectType number
) => "a")
)

// $ExpectType Option<[number | "a", ...(number | "a")[]]>
pipe(
nonEmptyNumbers,
Array.modifyOption(0, (
_n // $ExpectType number
) => "a" as const)
)

// $ExpectType Option<("a" | 1 | 2)[]>
pipe(
new Set([1, 2] as const),
Array.modifyOption(0, (
_n // $ExpectType 1 | 2
) => "a" as const)
)
16 changes: 16 additions & 0 deletions packages/effect/dtslint/Fiber.ts
Original file line number Diff line number Diff line change
@@ -0,0 1,16 @@
import { Fiber } from "effect"

declare const string: Fiber.Fiber<string>
declare const number: Fiber.Fiber<number>
declare const array: Array<Fiber.Fiber<string> | Fiber.Fiber<number>>

// awaitAll

// $ExpectType Effect<[Exit<string, never>, Exit<number, never>], never, never>
Fiber.awaitAll([string, number])

// $ExpectType Effect<(Exit<string, never> | Exit<number, never>)[], never, never>
Fiber.awaitAll(new Set([string, number]))

// $ExpectType Effect<(Exit<string, never> | Exit<number, never>)[], never, never>
Fiber.awaitAll(array)
48 changes: 39 additions & 9 deletions packages/effect/src/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,14 1049,23 @@ export const insertAt: {
* import { Array } from "effect"
*
* const letters = ['a', 'b', 'c', 'd']
* const result = Array.replace(1, 'z')(letters)
* const result = Array.replace(letters, 1, 'z')
* assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
*
* @since 2.0.0
*/
export const replace: {
<B>(i: number, b: B): <A>(self: Iterable<A>) => Array<A | B>
<A, B>(self: Iterable<A>, i: number, b: B): Array<A | B>
<B>(
i: number,
b: B
): <A, S extends Iterable<A> = Iterable<A>>(
self: S
) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
<A, B, S extends Iterable<A> = Iterable<A>>(
self: S,
i: number,
b: B
): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
} = dual(3, <A, B>(self: Iterable<A>, i: number, b: B): Array<A | B> => modify(self, i, () => b))

/**
Expand All @@ -1072,8 1081,15 @@ export const replace: {
* @since 2.0.0
*/
export const replaceOption: {
<B>(i: number, b: B): <A>(self: Iterable<A>) => Option<Array<A | B>>
<A, B>(self: Iterable<A>, i: number, b: B): Option<Array<A | B>>
<B>(
i: number,
b: B
): <A, S extends Iterable<A> = Iterable<A>>(self: S) => Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
<A, B, S extends Iterable<A> = Iterable<A>>(
self: S,
i: number,
b: B
): Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
} = dual(
3,
<A, B>(self: Iterable<A>, i: number, b: B): Option<Array<A | B>> => modifyOption(self, i, () => b)
Expand All @@ -1093,8 1109,15 @@ export const replaceOption: {
* @since 2.0.0
*/
export const modify: {
<A, B>(i: number, f: (a: A) => B): (self: Iterable<A>) => Array<A | B>
<A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Array<A | B>
<A, B, S extends Iterable<A> = Iterable<A>>(
i: number,
f: (a: ReadonlyArray.Infer<S>) => B
): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
<A, B, S extends Iterable<A> = Iterable<A>>(
self: S,
i: number,
f: (a: ReadonlyArray.Infer<S>) => B
): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
} = dual(
3,
<A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Array<A | B> =>
Expand All @@ -1118,8 1141,15 @@ export const modify: {
* @since 2.0.0
*/
export const modifyOption: {
<A, B>(i: number, f: (a: A) => B): (self: Iterable<A>) => Option<Array<A | B>>
<A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Option<Array<A | B>>
<A, B, S extends Iterable<A> = Iterable<A>>(
i: number,
f: (a: ReadonlyArray.Infer<S>) => B
): (self: S) => Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
<A, B, S extends Iterable<A> = Iterable<A>>(
self: S,
i: number,
f: (a: ReadonlyArray.Infer<S>) => B
): Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
} = dual(3, <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Option<Array<A | B>> => {
const out = Array.from(self)
if (isOutOfBound(i, out)) {
Expand Down
Loading