question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add method forwarders to `Resource`

See original GitHub issue

Resource implements Async, but does so in a purely “typeclassy” way. If you want to do something like rsrc.start (where rsrc: Resource[F, A]), you actually need to import cats.effect.syntax.all._! This isn’t a great experience.

Instead, we should flip all of this around and follow the same pattern IO does: move the definitions of these methods to Resource itself as members (taking the appropriate implicit evidence for F individually), and then change the typeclass implementations to simply forward the call onto the appropriate member function. This is actually a pretty easy change, just a little tedious and time-consuming. It should help with the ergonomics quite considerably though.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
alexandrustanacommented, Jul 12, 2021

I could try and tackle this one

2reactions
joroKr21commented, Jul 19, 2021

I thought the idea was to move the implementations themselves and forward to them from the type class like this:

trait Resource:
  def startOn(ec: ExecutionContext)(implicit F: Async[F]): Resource[F, Fiber[Resource[F, *], Throwable, A]] = ???
    // move implementation here

object Resource:
  implicit def asyncInstance[F[_]](implicit F: Async[F]) = new Async[Resource[F, *]] {
    def startOn[A](fa: Resource[F, A])(ec: ExecutionContext): Resource[F, Fiber[Resource[F, *], Throwable, A]] =
      fa.startOn(ec)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Method: forwardingRules.insert - Compute Engine
For Private Service Connect forwarding rules that forward traffic to Google APIs, the forwarding rule name must be a 1-20 characters string with ......
Read more >
Datadog Forwarder
Datadog Forwarder. The Datadog Forwarder is an AWS Lambda function that ships logs, custom metrics, and traces from your environment to Datadog.
Read more >
Use forwarders to get data into Splunk Cloud Platform
Forwarder instances that are remotely configured by deployment servers are called deployment clients. The deployment server downloads content ...
Read more >
Configuring Forwarding Profiles for Zscaler Client Connector
To configure a forwarding profile: Go to Administration > Forwarding Profile. Click Add Forwarding Profile. The Add Forwarding Profile window appears.
Read more >
Configure email forwarding for a mailbox in Exchange Online
Email forwarding lets you set up a mailbox to forward email messages ... permissions before you can perform this procedure or procedures.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found