@@ -705,7 +705,7 @@ _onException :: MonadCatch m => (a -> m c) -> Unfold m a b -> Unfold m a b
705_onException action unf =
705_onException action unf =
706 gbracket return MC.try
706 gbracket return MC.try
707 (\_ -> return ())
707 (\_ -> return ())
708− (nilM (\(a, (_ :: MC.SomeException)) -> action a)) unf
708+ (nilM (\(a, (e :: MC.SomeException)) -> action a >> MC.throwM e)) unf
710-- | Run a side effect whenever the unfold aborts due to an exception.
710-- | Run a side effect whenever the unfold aborts due to an exception.
@@ -732,7 +732,7 @@ onException action (Unfold step1 inject1) = Unfold step inject
732_finally :: MonadCatch m => (a -> m c) -> Unfold m a b -> Unfold m a b
732_finally :: MonadCatch m => (a -> m c) -> Unfold m a b -> Unfold m a b
733_finally action unf =
733_finally action unf =
734 gbracket return MC.try action
734 gbracket return MC.try action
735− (nilM (\(a, (_ :: MC.SomeException)) -> action a)) unf
735+ (nilM (\(a, (e :: MC.SomeException)) -> action a >> MC.throwM e)) unf
737-- | Run a side effect whenever the unfold stops normally or aborts due to an
737-- | Run a side effect whenever the unfold stops normally or aborts due to an
738-- exception.
738-- exception.
@@ -760,7 +760,8 @@ finally action (Unfold step1 inject1) = Unfold step inject
760_bracket :: MonadCatch m
760_bracket :: MonadCatch m
761 => (a -> m c) -> (c -> m d) -> Unfold m c b -> Unfold m a b
761 => (a -> m c) -> (c -> m d) -> Unfold m c b -> Unfold m a b
762_bracket bef aft unf =
762_bracket bef aft unf =
763− gbracket bef MC.try aft (nilM (\(a, (_ :: MC.SomeException)) -> aft a)) unf
763+ gbracket bef MC.try aft (nilM (\(a, (e :: MC.SomeException)) -> aft a >>
765-- | @bracket before after between@ runs the @before@ action and then unfolds
766-- | @bracket before after between@ runs the @before@ action and then unfolds
766-- its output using the @between@ unfold. When the @between@ unfold is done or
767-- its output using the @between@ unfold. When the @between@ unfold is done or