Skip to content

Commit

Permalink
change Fiber type parameters order from Fiber<E, A> to `Fiber<A, … (
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored and tim-smart committed Feb 9, 2024
1 parent d75f6fe commit 8b0ded9
Show file tree
Hide file tree
Showing 33 changed files with 209 additions and 199 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-readers-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

change `Fiber` type parameters order from `Fiber<E, A>` to `Fiber<A, E = never>`
7 changes: 6 additions & 1 deletion packages/effect/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ const enabled = {
swapDeferredParams: false,
swapTDeferredParams: false,
swapTakeParams: false,
swapFiberParams: true,
cleanupSTM: false,
cleanupEffect: false,
cleanupStream: false,
cleanupExit: false,
cleanupTake: true
cleanupTake: false
}

const cleanup = (name: string) => (ast: cs.ASTPath<cs.TSTypeReference>) => {
Expand Down Expand Up @@ -91,6 +92,7 @@ const swapParamsEA = (nodeName: string) => (ast: cs.ASTPath<cs.TSTypeReference>)
const swapDeferredParams = swapParamsEA("Deferred")
const swapTDeferredParams = swapParamsEA("TDeferred")
const swapTakeParams = swapParamsEA("Take")
const swapFiberParams = swapParamsEA("Fiber")

const swapSTMParams = swapParamsREA("STM")
const swapSTMGenParams = swapParamsREA("STMGen")
Expand Down Expand Up @@ -139,6 +141,9 @@ export default function transformer(file: cs.FileInfo, api: cs.API) {
if (enabled.swapTakeParams) {
swapTakeParams(ast)
}
if (enabled.swapFiberParams) {
swapFiberParams(ast)
}
if (enabled.cleanupEffect) {
cleanupEffect(ast)
}
Expand Down
20 changes: 10 additions & 10 deletions packages/effect/src/Effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2547,11 +2547,11 @@ export const diffFiberRefs: <A, E, R>(
*/
export const ensuringChild: {
<X, R2>(
f: (fiber: Fiber.Fiber<any, ReadonlyArray<unknown>>) => Effect<X, never, R2>
f: (fiber: Fiber.Fiber<ReadonlyArray<unknown>, any>) => Effect<X, never, R2>
): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R2 | R>
<A, E, R, X, R2>(
self: Effect<A, E, R>,
f: (fiber: Fiber.Fiber<any, ReadonlyArray<unknown>>) => Effect<X, never, R2>
f: (fiber: Fiber.Fiber<ReadonlyArray<unknown>, any>) => Effect<X, never, R2>
): Effect<A, E, R | R2>
} = circular.ensuringChild

Expand Down Expand Up @@ -2634,7 +2634,7 @@ export const forkAll: {
options?: {
readonly discard?: false | undefined
}
): <A, E, R>(effects: Iterable<Effect<A, E, R>>) => Effect<Fiber.Fiber<E, Array<A>>, never, R>
): <A, E, R>(effects: Iterable<Effect<A, E, R>>) => Effect<Fiber.Fiber<Array<A>, E>, never, R>
(options: {
readonly discard: true
}): <A, E, R>(effects: Iterable<Effect<A, E, R>>) => Effect<void, never, R>
Expand All @@ -2643,7 +2643,7 @@ export const forkAll: {
options?: {
readonly discard?: false | undefined
}
): Effect<Fiber.Fiber<E, Array<A>>, never, R>
): Effect<Fiber.Fiber<Array<A>, E>, never, R>
<A, E, R>(effects: Iterable<Effect<A, E, R>>, options: {
readonly discard: true
}): Effect<void, never, R>
Expand Down Expand Up @@ -2693,7 +2693,7 @@ export const forkWithErrorHandler: {
* @since 2.0.0
* @category supervision & fibers
*/
export const fromFiber: <E, A>(fiber: Fiber.Fiber<E, A>) => Effect<A, E> = circular.fromFiber
export const fromFiber: <E, A>(fiber: Fiber.Fiber<A, E>) => Effect<A, E> = circular.fromFiber

/**
* Creates an `Effect` value that represents the exit value of the specified
Expand All @@ -2702,7 +2702,7 @@ export const fromFiber: <E, A>(fiber: Fiber.Fiber<E, A>) => Effect<A, E> = circu
* @since 2.0.0
* @category supervision & fibers
*/
export const fromFiberEffect: <A, E, R>(fiber: Effect<Fiber.Fiber<E, A>, E, R>) => Effect<A, E, R> =
export const fromFiberEffect: <A, E, R>(fiber: Effect<Fiber.Fiber<A, E>, E, R>) => Effect<A, E, R> =
circular.fromFiberEffect

/**
Expand Down Expand Up @@ -3695,16 +3695,16 @@ export const raceWith: {
<A1, E1, R1, E, A, A2, E2, R2, A3, E3, R3>(
other: Effect<A1, E1, R1>,
options: {
readonly onSelfDone: (exit: Exit.Exit<A, E>, fiber: Fiber.Fiber<E1, A1>) => Effect<A2, E2, R2>
readonly onOtherDone: (exit: Exit.Exit<A1, E1>, fiber: Fiber.Fiber<E, A>) => Effect<A3, E3, R3>
readonly onSelfDone: (exit: Exit.Exit<A, E>, fiber: Fiber.Fiber<A1, E1>) => Effect<A2, E2, R2>
readonly onOtherDone: (exit: Exit.Exit<A1, E1>, fiber: Fiber.Fiber<A, E>) => Effect<A3, E3, R3>
}
): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R1 | R2 | R3 | R>
<A, E, R, A1, E1, R1, A2, E2, R2, A3, E3, R3>(
self: Effect<A, E, R>,
other: Effect<A1, E1, R1>,
options: {
readonly onSelfDone: (exit: Exit.Exit<A, E>, fiber: Fiber.Fiber<E1, A1>) => Effect<A2, E2, R2>
readonly onOtherDone: (exit: Exit.Exit<A1, E1>, fiber: Fiber.Fiber<E, A>) => Effect<A3, E3, R3>
readonly onSelfDone: (exit: Exit.Exit<A, E>, fiber: Fiber.Fiber<A1, E1>) => Effect<A2, E2, R2>
readonly onOtherDone: (exit: Exit.Exit<A1, E1>, fiber: Fiber.Fiber<A, E>) => Effect<A3, E3, R3>
}
): Effect<A2 | A3, E2 | E3, R | R1 | R2 | R3>
} = fiberRuntime.raceWith
Expand Down
Loading

0 comments on commit 8b0ded9

Please sign in to comment.