Skip to content

Commit

Permalink
Fix STM unification (#4412)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhraksMamtsov authored Feb 6, 2025
1 parent 58a6f9d commit e30f132
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-rules-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Fix STM unification
12 changes: 11 additions & 1 deletion packages/effect/dtslint/Unify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type * as RcRef from "effect/RcRef"
import type * as Ref from "effect/Ref"
import type * as Resource from "effect/Resource"
import type * as ScopedRef from "effect/ScopedRef"
import type * as STM from "effect/STM"
import type * as Stream from "effect/Stream"
import type * as SubscriptionRef from "effect/SubscriptionRef"
import type * as SynchronizedRef from "effect/SynchronizedRef"
Expand Down Expand Up @@ -62,6 +63,13 @@ hole<
| Effect.Effect<"a", "b", "c">
>
>()
// $ExpectType STM<0 | "a", "b" | 1, "c" | 2>
hole<
Unify.Unify<
| STM.STM<0, 1, 2>
| STM.STM<"a", "b", "c">
>
>()

// $ExpectType Exit<0 | "a", "b" | 1>
hole<
Expand Down Expand Up @@ -182,7 +190,7 @@ hole<
>
>()

// $ExpectType 0 | Option<string | number> | Ref<1> | Ref<"a"> | SynchronizedRef<1> | SynchronizedRef<"a"> | SubscriptionRef<1> | SubscriptionRef<"a"> | Deferred<"a", "b"> | FiberRef<1> | FiberRef<"a"> | ManagedRuntime<"a", "b"> | Queue<1> | Queue<"a"> | Dequeue<"a" | 1> | Pool<1, 2> | Pool<"a", "b" | "c"> | ScopedRef<1> | ScopedRef<"a"> | Resource<"a", "b"> | Deferred<1, 0> | Resource<1, 0> | Latch | ManagedRuntime<1, 0> | RcRef<"a" | 1, 0 | "b"> | Fiber<"a" | 1, 0 | "b"> | RuntimeFiber<"a" | 1, 0 | "b"> | Either<"a" | 1, 0 | "b"> | Effect<"a" | 1, 0 | "b", "R" | "R1">
// $ExpectType 0 | Option<string | number> | STM<0 | "a", "b" | 1, "c" | 2> | Ref<1> | Ref<"a"> | SynchronizedRef<1> | SynchronizedRef<"a"> | SubscriptionRef<1> | SubscriptionRef<"a"> | Deferred<"a", "b"> | FiberRef<1> | FiberRef<"a"> | ManagedRuntime<"a", "b"> | Queue<1> | Queue<"a"> | Dequeue<"a" | 1> | Pool<1, 2> | Pool<"a", "b" | "c"> | ScopedRef<1> | ScopedRef<"a"> | Resource<"a", "b"> | Deferred<1, 0> | Resource<1, 0> | Latch | ManagedRuntime<1, 0> | RcRef<"a" | 1, 0 | "b"> | Fiber<"a" | 1, 0 | "b"> | RuntimeFiber<"a" | 1, 0 | "b"> | Either<"a" | 1, 0 | "b"> | Effect<"a" | 1, 0 | "b", "R" | "R1">
hole<
Unify.Unify<
| Either.Either<1, 0>
Expand All @@ -191,6 +199,8 @@ hole<
| Option.Option<string>
| Effect.Effect<"a", "b", "R">
| Effect.Effect<1, 0, "R1">
| STM.STM<0, 1, 2>
| STM.STM<"a", "b", "c">
| Ref.Ref<1>
| Ref.Ref<"a">
| SynchronizedRef.SynchronizedRef<1>
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/STM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface STM<out A, out E = never, out R = never>
* @category models
*/
export interface STMUnify<A extends { [Unify.typeSymbol]?: any }> extends Effect.EffectUnify<A> {
STM?: () => A[Unify.typeSymbol] extends STM<infer A0, infer E0, infer R0> | infer _ ? STM<R0, E0, A0> : never
STM?: () => A[Unify.typeSymbol] extends STM<infer A0, infer E0, infer R0> | infer _ ? STM<A0, E0, R0> : never
}

/**
Expand Down

0 comments on commit e30f132

Please sign in to comment.