Refactor client into algebra #2102
Conversation
Note that almost every middleware is expressed in terms of |
def go[A](r: Resource[F, A]): F[(A, F[Unit])] = r match { | ||
case Resource.Allocate(r) => | ||
r.map { case (a, release) => (a, release(ExitCase.Completed)) } | ||
case Resource.Bind(r, f) => |
rossabaker
Sep 22, 2018
Author
Member
I am sleepy and this feels dangerous. Please be extra careful reviewing this.
I am sleepy and this feels dangerous. Please be extra careful reviewing this.
ChristopherDavenport
Sep 24, 2018
Member
😟
rossabaker
Sep 24, 2018
Author
Member
It probably pays to go back and understand why Resource
has this ADT instead of being a wrapper around Allocate
's value, because we're basically reconstructing that.
(This is also a suggestion for myself.)
It probably pays to go back and understand why Resource
has this ADT instead of being a wrapper around Allocate
's value, because we're basically reconstructing that.
(This is also a suggestion for myself.)
I have not tried the metrics, I have only compiled them. This is going to cause a merge conflict with #2094, so we need to give one of them the right of way. |
The diff is a little smaller if you ignore whitespace. |
Similar to, and supersedes, #1772. |
Looks good. DisposableResponse never really tasted right :) |
case (a, rel) => | ||
stack match { | ||
case Nil => F.pure(a -> release.guarantee(rel(ExitCase.Completed))) | ||
case f0 :: xs => continue(f0(a), xs, release.guarantee(rel(ExitCase.Completed))) |
rossabaker
Sep 26, 2018
Author
Member
We release in reverse order, so I think these guarantees are both backward? We don't yet have a test that exposes this.
We release in reverse order, so I think these guarantees are both backward? We don't yet have a test that exposes this.
DisposableResponse
is goneClient
is a trait with no concrete methodsDefaultClient
implements them all in terms of arun: Request[F] => Resource[F, Response[F]]
shutdown
: we create clients asResource
s.