Skip to content

Deferred with different effects for source and sink - #1583

Closed
durban wants to merge 1 commit into
typelevel:series/3.xfrom
durban:deferred2
Closed

Deferred with different effects for source and sink#1583
durban wants to merge 1 commit into
typelevel:series/3.xfrom
durban:deferred2

Conversation

@durban

@durban durban commented Jan 7, 2021

Copy link
Copy Markdown
Contributor

This generalizes Deferred to allow different effects for its DeferredSource and DeferredSink parts. So instead of Deferred[F, A] we could have Deferred2[F, G, A], which we can get in F and complete in G.

This is a work in progress. If the general idea is acceptable, I'll work on at least the following:

  • The names are terrible (Deferred2, in2, ...); I'm open to suggestions.
  • Scaladoc may need changes.

@durban

durban commented Jan 7, 2021

Copy link
Copy Markdown
Contributor Author

Also, I'm unsure about the following:

  • What to do with GenConcurrent#deferred? I left it alone for now.
  • Related to the previous point: should I create a Deferred.Make typeclass (similar to Ref.Make)?

@SystemFw

SystemFw commented Jan 7, 2021

Copy link
Copy Markdown
Contributor

My 2c:
I would personally prefer to keep deferred simple, as it's now part of our primitive building blocks due to its inclusion in the typeclass hierarchy. If we want to introduce this abstraction, it could be a different thing, with a different set of use cases (e.g InteropChannel), and I would also explore if it can be implemented generically for any Async, given Dispatcher.

Let's see what others think :)

@durban

durban commented Jan 8, 2021

Copy link
Copy Markdown
Contributor Author

There is no need for Dispatcher. It works for any F[_] : Async and G[_] : Sync.

@SystemFw

SystemFw commented Jan 8, 2021

Copy link
Copy Markdown
Contributor

yeah sorry, I was thinking "see if it can be done without relying on effect capture", but that's a pointless requirement since Dispatcher will require Async anyway :)

@djspiewak

Copy link
Copy Markdown
Member

It's a cool generalization, but it definitely feels like a much higher degree of complexity. I think if this were just a separate thing in the std lib then I'd be in favor of making a generalized Deferred2 with two effects with a specialized Deferred type alias for one, but given that it's part of the core axioms, I think it's better to not open that pandora's box.

@djspiewak djspiewak closed this Jan 24, 2021
@durban durban mentioned this pull request Feb 6, 2022
@armanbilge armanbilge mentioned this pull request Feb 12, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants