Fs2: Rework Stream#translate

Created on 12 Oct 2020  Â·  3Comments  Â·  Source: typelevel/fs2

Translation of a stream's effect type is currently supported via Stream#translate and Stream#translateInterruptible. Translation is eagerly applied. Due to some forthcoming changes to cats.effect.Resource (https://github.com/typelevel/cats-effect/issues/1255) as well as the desire to support interruptible resource acquisition (#2077), we may need to move translation to be a constructor in the stream algebra.

Some discussion: https://gitter.im/typelevel/cats-effect-dev?at=5f830fe3a1c81d0a7ed68025

help wanted

All 3 comments

@diesalbla Any interest in working on this one? You know the internals as well as anyone, especially the translation stuff.

@mpilquist I will take a look later today.

Adding here for context some of the discussions:

So, [the current implementation] applies eagerly to the algebra. TBH, I think the only hope here is to try to get the evaluation of translate pushed into the actual compilation loop, which means giving it a first class case in the algebra.
I would try to do that independent of poll like, if that's doable, then poll should have a solution there (that should also eliminate the need for translateInterruptible btw). But… if that's not doable then we have a bit of a problem. By Daniel Spjiewak

Easy enough to add a Translate case, but i have no idea how to implement the case t: Translate[…] handler in Pull.compile.go, which needs to call view.next(..) with def next(r: Result[X]): Pull[F, O, R]. By @mpilquist

Given that we can have many translations of streams nested with other stream translations, we would have to attach a FunctionK[F, G] to the compile loop, as a new parameter. S

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gvolpe picture gvolpe  Â·  9Comments

shn-amn picture shn-amn  Â·  3Comments

mpilquist picture mpilquist  Â·  12Comments

mpilquist picture mpilquist  Â·  14Comments

gvolpe picture gvolpe  Â·  10Comments