-
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
Less restrictive DataSource effect implicits #163
Comments
I think with |
Would it be possible to make the restriction to |
2 cents from the peanut gallery for what it's worth... From a users perspective moving from earlier versions of Fetch, it was very surprising to me to have to sprinkle implicit def fetchString[F[_] : ConcurrentEffect](n: Int): Fetch[F, String] =
Fetch(n, ToStringSource)
//Why do I need to do all of this in order to interpret a Fetch into an IO?
//I understand *why* but it's counter-intuitive given that when we
//run the Fetch to produce the IO we still haven't generated any side-effects.
val ec: ExecutionContext = implicitly[ExecutionContext]
implicit val timer: Timer[IO] = IO.timer(ec)
implicit val cs: ContextShift[IO] = IO.contextShift(ec)
val io: IO[String] = Fetch.run[IO](fetchString(123))
val task: Task[String] = Task.fromEffect(io) So if I've got code like this: trait KVStore{
def get(key: String): Task[String]
} within which I'm trying to use trait KVStore{
def get(key: String)(implicit ec: ExecutionContext): Task[String]
} I'm not sure of the details of Thinking about this more... would it be possible to interpret a |
We use
About Thanks for your feedback, I'll get back to this issue when I make some progress. If you have any ideas/proofs-of-concept for making implicits less restrictive I'm happy to review and merge PRs too. |
I think
It's a very small library that's actually endorsed by cats maintainers until cats breaks binary compatibility (see gitter channel). I wouldn't consider this a major obstacle :) I'm all +1 for getting rid of any Effect constraints. They should be used as rarely as possible. |
I think I disagree know with what I said almost 6 months ago as well, and I agree that we should look if we can't get by with just |
Would you feel any different about Par if cats-par was officially endorsed by typelevel? Here are all the reasons I found not to require Concurrent:
FYI ContextShift is completely unused in the code for fetch, too, so the only thing that remains is Clock, usage of which could be superseded by a custom algebra for measuring time (allowing custom implementations that'd simply return a dumb value for tests). |
We removed it because we only wanted to depend on cats-effect, introducing |
Currently the methods that fetch data in
DataSource
require an effect typeF
withPar[F]
andConcurrentEffect[F]
.Par
is required due to theDataSource#batch
implementation defaulting to running individual fetches in parallel. If we move away from it, Data sources that don't implement batching will run their fetches sequentially.Par[F]
will still be required when creating or running a fetch toF
, since is used when running multiple batches in parallel.ConcurrentEffect
is perhaps too restrictive, since we may not need the cancellation semantics thatConcurrent
provides. We could useEffect
here, thoughts?The text was updated successfully, but these errors were encountered: