Minor Changes
-
#2101
5de7be5
Thanks @github-actions! - remove ReadonlyRecord.fromIterable (duplicate of fromEntries) -
#2101
489fcf3
Thanks @github-actions! - - swapSchedule
type parameters fromSchedule<out Env, in In, out Out>
toSchedule<out Out, in In = unknown, out R = never>
, closes #2154- swap
ScheduleDriver
type parameters fromScheduleDriver<out Env, in In, out Out>
toScheduleDriver<out Out, in In = unknown, out R = never>
- swap
-
#2101
7d9c3bf
Thanks @github-actions! - ConsolidateEffect.asyncOption
,Effect.asyncEither
,Stream.asyncOption
,Stream.asyncEither
, andStream.asyncInterrupt
This PR removes
Effect.asyncOption
andEffect.asyncEither
as their behavior can be entirely implemented with the new signature ofEffect.async
, which optionally returns a cleanupEffect
from the registration callback.declare const async: <A, E = never, R = never>( register: ( callback: (_: Effect<A, E, R>) => void, signal: AbortSignal, ) => void | Effect<void, never, R>, blockingOn?: FiberId, ) => Effect<A, E, R>;
Additionally, this PR removes
Stream.asyncOption
,Stream.asyncEither
, andStream.asyncInterrupt
as their behavior can be entirely implemented with the new signature ofStream.async
, which can optionally return a cleanupEffect
from the registration callback.declare const async: <A, E = never, R = never>( register: (emit: Emit<R, E, A, void>) => Effect<void, never, R> | void, outputBuffer?: number, ) => Stream<A, E, R>;
-
#2101
d8d278b
Thanks @github-actions! - swapGroupBy
type parameters fromGroupBy<out R, out E, out K, out V>
toGroupBy<out K, out V, out E = never, out R = never>
-
#2101
14c5711
Thanks @github-actions! - Remove Effect.unified and Effect.unifiedFn in favour of Unify.unify.The
Unify
module fully replaces the need for specific unify functions, when before you did:import { Effect } from "effect"; const effect = Effect.unified( Math.random() > 0.5 ? Effect.succeed("OK") : Effect.fail("NO"), ); const effectFn = Effect.unifiedFn((n: number) => Math.random() > 0.5 ? Effect.succeed("OK") : Effect.fail("NO"), );
You can now do:
import { Effect, Unify } from "effect"; const effect = Unify.unify( Math.random() > 0.5 ? Effect.succeed("OK") : Effect.fail("NO"), ); const effectFn = Unify.unify((n: number) => Math.random() > 0.5 ? Effect.succeed("OK") : Effect.fail("NO"), );
-
#2101
5de7be5
Thanks @github-actions! - add key type to ReadonlyRecord -
#2101
585fcce
Thanks @github-actions! - add support for optional property keys topick
,omit
andget
Before:
import { pipe } from "effect/Function"; import * as S from "effect/Struct"; const struct: { a?: string; b: number; c: boolean; } = { b: 1, c: true }; // error const x = pipe(struct, S.pick("a", "b")); const record: Record<string, number> = {}; const y = pipe(record, S.pick("a", "b")); console.log(y); // => { a: undefined, b: undefined } // error console.log(pipe(struct, S.get("a")));
Now
import { pipe } from "effect/Function"; import * as S from "effect/Struct"; const struct: { a?: string; b: number; c: boolean; } = { b: 1, c: true }; const x = pipe(struct, S.pick("a", "b")); console.log(x); // => { b: 1 } const record: Record<string, number> = {}; const y = pipe(record, S.pick("a", "b")); console.log(y); // => {} console.log(pipe(struct, S.get("a"))); // => undefined
-
#2101
a025b12
Thanks @github-actions! - Swap type params of Either fromEither<E, A>
toEither<R, L = never>
.Along the same line of the other changes this allows to shorten the most common types such as:
import { Either } from "effect"; const right: Either.Either<string> = Either.right("ok");
Patch Changes
-
#2193
b9cb3a9
Thanks @jessekelly881! - added Number.parse, BigInt.toNumber, ParseResult.fromOption -
#2101
93b412d
Thanks @github-actions! - ReadonlyArray.groupBy: allow for grouping by symbols, closes #2180 -
#2101
55b26a6
Thanks @github-actions! - Either: fixfromOption
overloads order -
#2101
2097739
Thanks @github-actions! - Add Do notation methodsDo
,bindTo
,bind
andlet
to Either