chimney
chimney copied to clipboard
TransformerFSupport for cats-effect Sync
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).
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 👍
Closing, as lifted transformers are deprecated.