typelevel / fs2

Compositional, streaming I/O library for Scala
https://fs2.io
Other
2.38k stars 603 forks source link

Add `TransformedSignallingRef` a la `TransformedRef` #3460

Open jhenahan opened 4 months ago

jhenahan commented 4 months ago

In the work code, I need to lift a SignallingRef into a trace4cats flow, which requires a SignallingRef[F, A] => F ~> G => SignallingRef[G, A]. Unfortunately, .mapK on SignallingRef[F, A] yields a Ref[G, A]. I implemented a

class TransformedSignallingRef[F[_], G[_], A](underlying: SignallingRef[F, A], fk: F ~> G)(implicit ev: Functor[F])

with essentially the same implementation as TransformedRef in cats-effect, I just can't PR it until I've cleared it with the company. The implementation is totally mechanical, though, so I wouldn't be mad if someone beat me to it before I get that done.

If there's already a way to get this kind of translation done without adding this, I'd also be very happy to hear about it.

FS2 version: 3.10.2