-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC: Redesign without IO
#156
Conversation
shared/src/main/scala/fetch.scala
Outdated
cache: DataSourceCache = InMemoryCache.empty | ||
def run[F[_]: Sync: Par, A]( | ||
fa: Fetch[F, A], | ||
cache: DataSourceCache[F] = InMemoryCache.empty[F] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't compile because the call to .empty
requires the implicit Sync
instance, which is in the implicit argument list that follows, but that is not important to the concept.
env: Option[Ref[IO, Env]] | ||
private def performRun[F[_]: Sync: Par, A]( | ||
fa: Fetch[F, A], | ||
cache: Ref[F, DataSourceCache[F]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't need IO
, just an implicit Sync
shared/src/main/scala/fetch.scala
Outdated
for { | ||
deferred <- Deferred[IO, FetchStatus] | ||
deferred <- Deferred[F, FetchStatus] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't need IO
, just an implicit Concurrent
Interesting, thanks for the PR. I'm going to update it to match what's in |
@gatorcse great stuff 👏 . The clear advantage of being more generic is that we can run Fetch to monix Task and any other data type that already provides instances for cats-effect. |
287ae8b
to
d805c08
Compare
I managed to make it compile, removing the Awesome work @gatorcse, thanks for doing the heavy lifting with this changes. |
Added these improvements to #155 ✨ |
I experimented with changing #155 to not require
IO
. The stated reasons for specifyingIO
were forRef
andDeferred
, but those only requireSync
andConcurrent
respectively. I wanted to see if we could remove the requirement for IO, allowing Monix or other implementations to be used.This is just a proof of concept. I didn't update the tests or anything, it also adds a
F[_]
parameter all over the place. This can probably be wrapped up in an abstract class or something to simplify the API. I just wanted to see if it would work.