You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fact that Stream[F, O] can be easily got from Pull[F, O, Unit] is severely used in this example.
Stream's bracket API does not allow the release action to emit output values, since it takes F[...], not Stream[F, ...]. But, Pull's bracket API does allow to emit values, since it takesPull[F, O, Unit] as a release action.
Possibly unexpected situation
Consider now a situation when I have some effect after some emit in the release action of some bracket of some Pull. Now consider that I converted this to a Stream and flatMap'ed on it and in the RHS side of this flatMap an error occurs. You can see illustrating code for this. Do you expect an effect in the release action, which goes after the emit to occur? I did, at least at first, but actually, at least on v3.5.0 release action do not finish all its actions.
Later I realised that maybe this can be thought of as expected semantics since flatMap'ing on Streams actually means that we kinda insert intermediate actions instead of emits of a stream on LHS, so it this action fails, the whole stream fails no matter it is a release function. Kind of, you must watch (and maybe guard) your emits in the release action, if you have one.
Despite that, I had a little discussion with other developers who agreed that despite this explanation, they would expect all effects in the release action to be executed because of pragmatics of it.
Definitely unexpected situation
Okay, let's guard the final effectful action which should go after emit in the release action. To do this, let's make another bracket. You can see example of this change here. But, this bracket in the release action simply does not work as a bracket, and this is completely unexpected.
The text was updated successfully, but these errors were encountered:
Context
The fact that
Stream[F, O]
can be easily got fromPull[F, O, Unit]
is severely used in this example.Stream
's bracket API does not allow the release action to emit output values, since it takesF[...]
, notStream[F, ...]
. But,Pull
's bracket API does allow to emit values, since it takesPull[F, O, Unit]
as a release action.Possibly unexpected situation
Consider now a situation when I have some effect after some emit in the release action of some bracket of some
Pull
. Now consider that I converted this to aStream
andflatMap
'ed on it and in the RHS side of thisflatMap
an error occurs. You can see illustrating code for this. Do you expect an effect in the release action, which goes after the emit to occur? I did, at least at first, but actually, at least on v3.5.0 release action do not finish all its actions.Later I realised that maybe this can be thought of as expected semantics since
flatMap
'ing onStreams
actually means that we kinda insert intermediate actions instead of emits of a stream on LHS, so it this action fails, the whole stream fails no matter it is a release function. Kind of, you must watch (and maybe guard) your emits in the release action, if you have one.Despite that, I had a little discussion with other developers who agreed that despite this explanation, they would expect all effects in the release action to be executed because of pragmatics of it.
Definitely unexpected situation
Okay, let's guard the final effectful action which should go after emit in the release action. To do this, let's make another bracket. You can see example of this change here. But, this bracket in the release action simply does not work as a bracket, and this is completely unexpected.
The text was updated successfully, but these errors were encountered: