effect icon indicating copy to clipboard operation
effect copied to clipboard

DX improvement: Support `yield*` in even more places: Fibers, Deferreds, ...

Open schickling opened this issue 1 year ago • 4 comments

What is the problem this feature would solve?

Using the Effect generator syntax is really nice as some data types are "yieldable" however even more data types could be yieldable.

What is the feature you are proposing to solve the problem?

DX improvement: Support yield* in even more places: Fibers, Deferreds, ...

What alternatives have you considered?

No response

schickling avatar Aug 25 '24 09:08 schickling

clarification: make Fiber, Ref, Deferred, etc subtypes of Effect

mikearnaldi avatar Aug 25 '24 09:08 mikearnaldi

@mikearnaldi , What subtype should Fiber be?

semantics
Fiber<A, E> Effect<A, E> Fiber.join
Fiber<A, E> Effect<Exit<A, E>> Fiber.await
// Fiber.join semantic
const value = yield* joinFiber
// Fiber.await
const exit = yield* awaitFiber 
const value = yield* exit

the first case can be expressed by the second one , but not vice versa

KhraksMamtsov avatar Sep 09 '24 18:09 KhraksMamtsov

@mikearnaldi , What subtype should Fiber be?

semantics Fiber<A, E> Effect<A, E> Fiber.join Fiber<A, E> Effect<Exit<A, E>> Fiber.await

// Fiber.join semantic
const value = yield* joinFiber
// Fiber.await
const exit = yield* awaitFiber 
const value = yield* exit

the first case can be expressed by the second one , but not vice versa

they are semantically different, joining also merges fiber references while awaiting doesn't. I think along the lines of the rest I'd expect join to be the semantic of yielding

mikearnaldi avatar Sep 09 '24 18:09 mikearnaldi

Are there any other entities that can be affected? Resource, Pool, PubSub? or is there no need for it yet?

KhraksMamtsov avatar Sep 15 '24 11:09 KhraksMamtsov