-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streaming exposes an unsafe destroy #34
Comments
I think the cleaned up version probably looks like this: destroy
:: (Functor f, Monad m) =>
Stream f m r -> (f b -> b) -> (m b -> b) -> (r -> b) -> b
destroy s construct effect done = effect (loop s) where
loop stream = case stream of
Step fs -> return (construct (fmap (effect . loop) fs))
Effect m -> m >>= loop
Return r -> return (done r) |
FYI, it appears this bug was introduced in e2ab123. I believe my implementation likely does a better job of fusing code than the previous working version did, but I haven't tried benchmarking that. |
This is no longer the official repo for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By the monad transformer laws,
foo = bar
, but in factdestroy foo P.show P.show P.show /= destroy bar P.show P.show P.show
. I blamedestroy
. Indeed,Streaming.Internal.destroyExposed
carefully documents the dangers and necessary restrictions, butdestroy
is (presumably accidentally) implemented using identical code:The most obvious fix is to simply define
but there may be a slightly more efficient way.
The text was updated successfully, but these errors were encountered: