chimney icon indicating copy to clipboard operation
chimney copied to clipboard

TransformerFSupport for cats-effect Sync

Open kubukoz opened this issue 4 years ago • 1 comments

I would like to have a transformer with effects (or maybe just some validations, but in the same effect as the rest of the logic in the same trait).

Since there's no support for that now, It would be nice to provide TransformerFSupport for any F[_]: Sync. Normally ApplicativeError would've been enough, but since there's direct usage of iterator methods, they should be suspended in the effect. Unless the API of TransformerFSupport is changed, the iterator calls should wrapped in Sync[F].delay, and the while loop should be replaced with an appropriate whileM or something similar, effect-aware (in comparison to the implementation for Either).

kubukoz avatar Jul 06 '20 17:07 kubukoz

My concern about integration with Sync is that it doesn't belong to cats-core, but to cats-effect which means either depending on it in chimney-cats (bad) or introducing another integration module chimney-cats-effects (also bad?).

As far as I understand ApplicativeError, it allows you to raise/handle single error, but in case of nested wrapped transformers, you may want to be interested in gathering all the errors, so I think AE leads to wrong abstraction here.

There is also a lot of confusion about implementing traverse for TransformerFSupport. Iterator provided to this method has the underlying data structure already materialized, so there are essentially no effects other than consuming the iterator, which you have guarantee that is local to the traverse function. More attention should be paid to provide efficient implementation that doesn't produce any ephemeral garbage.

Either way, PRs welcome 👍

krzemin avatar Jul 08 '20 17:07 krzemin

Closing, as lifted transformers are deprecated.

krzemin avatar Feb 24 '23 20:02 krzemin