Skip to content
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

Add a function on Resource that turns it into an F ~> F #1338

Closed
kubukoz opened this issue Oct 19, 2020 · 6 comments
Closed

Add a function on Resource that turns it into an F ~> F #1338

kubukoz opened this issue Oct 19, 2020 · 6 comments
Assignees

Comments

@kubukoz
Copy link
Member

kubukoz commented Oct 19, 2020

It would make the resource wrap an effect in an usage, ignoring the value produced by the resource.

Possible signature:

trait Resource[+F[_], +A] { self =>
  //...

  //some constraint might be required on G
  def surround[G[x] >: F[x]]: G ~> G = new (G ~> G) { def apply[A](ga: G[A]): G[A] = self.use(_ => ga) }
}
@SystemFw
Copy link
Contributor

I like the idea but I think that specific signature is cumbersome to use, i.e

surround[IO].apply(IO(1))

vs

surround(IO(1))

@kubukoz
Copy link
Member Author

kubukoz commented Oct 19, 2020

I wonder if .surround.apply(IO(1)) would just work...

@bplommer
Copy link
Contributor

How about having .surround just take the thing to be surrounded (surroundee?) directly as an argument, and have .surroundK to return a FunctionK?

@kubukoz
Copy link
Member Author

kubukoz commented Oct 20, 2020

Sounds good to me, that way should be even more ergonomic :)

@pkowalcze
Copy link
Contributor

Is it okay if I give this task a try?

@RaasAhsan
Copy link

@pkowalcze Go to town :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants