@@ -9,13 +9,13 @@
99module Streamly.Internal.Data.Stream.Exception
1010 (
1111 before
12− , after_
12+ , afterUnsafe
1313 , afterIO
14− , bracket_
14+ , bracketUnsafe
1515 , bracketIO
1616 , bracket3IO
1717 , onException
18− , finally_
18+ , finallyUnsafe
1919 , finallyIO
2020 , ghandle
2121 , handle
@@ -59,13 +59,13 @@ before action xs = fromStreamD $ D.before action $ toStreamD xs
5959--
6060-- Same as the following, but with stream fusion:
6161--
62−-- >>> after_ action xs = xs <> Stream.nilM action
62+-- >>> afterUnsafe action xs = xs <> Stream.nilM action
6363--
6464-- /Pre-release/
6565--
66−{-# INLINE after_ #-}
67−after_ :: Monad m => m b -> Stream m a -> Stream m a
68−after_ action xs = fromStreamD $ D.after_ action $ toStreamD xs
66+{-# INLINE afterUnsafe #-}
67+afterUnsafe :: Monad m => m b -> Stream m a -> Stream m a
68+afterUnsafe action xs = fromStreamD $ D.after_ action $ toStreamD xs
6969
7070-- | Run the action @IO b@ whenever the stream stream stops normally, or
7171-- if it is garbage collected after a partial lazy evaluation.
@@ -73,7 +73,7 @@ after_ action xs = fromStreamD $ D.after_ action $ toStreamD xs
7373-- The semantics of the action @IO b@ are similar to the semantics of cleanup
7474-- action in 'bracketIO'.
7575--
76−-- /See also 'after_'/
76+-- /See also 'afterUnsafe'/
7777--
7878{-# INLINE afterIO #-}
7979afterIO :: MonadIO m => IO b -> Stream m a -> Stream m a
@@ -98,9 +98,9 @@ onException action xs = fromStreamD $ D.onException action $ toStreamD xs
9898--
9999-- /Pre-release/
100100--
101−{-# INLINE finally_ #-}
102−finally_ :: MonadCatch m => m b -> Stream m a -> Stream m a
103−finally_ action xs = fromStreamD $ D.finally_ action $ toStreamD xs
101+{-# INLINE finallyUnsafe #-}
102+finallyUnsafe :: MonadCatch m => m b -> Stream m a -> Stream m a
103+finallyUnsafe action xs = fromStreamD $ D.finally_ action $ toStreamD xs
104104
105105-- | Run the action @IO b@ whenever the stream stream stops normally, aborts
106106-- due to an exception or if it is garbage collected after a partial lazy
@@ -111,7 +111,7 @@ finally_ action xs = fromStreamD $ D.finally_ action $ toStreamD xs
111111--
112112-- >>> finallyIO release = Stream.bracketIO (return ()) (const release)
113113--
114−-- /See also 'finally_'/
114+-- /See also 'finallyUnsafe'/
115115--
116116-- /Inhibits stream fusion/
117117--
@@ -131,11 +131,10 @@ finallyIO action xs = fromStreamD $ D.finally action $ toStreamD xs
131131--
132132-- /Pre-release/
133133--
134−{-# INLINE bracket_ #-}
135−bracket_ :: MonadCatch m
134+{-# INLINE bracketUnsafe #-}
135+bracketUnsafe :: MonadCatch m
136136 => m b -> (b -> m c) -> (b -> Stream m a) -> Stream m a
137−bracket_ bef aft bet = fromStreamD $
138− D.bracket_ bef aft (toStreamD . bet)
137+bracketUnsafe bef aft bet = fromStreamD $ D.bracket_ bef aft (toStreamD . bet)
139138
140139-- | Run the alloc action @IO b@ with async exceptions disabled but keeping
141140-- blocking operations interruptible (see 'Control.Exception.mask'). Use the
@@ -154,7 +153,7 @@ bracket_ bef aft bet = fromStreamD $
154153-- immediately in the current thread context, whereas in other cases it runs in
155154-- the GC context, therefore, cleanup may be delayed until the GC gets to run.
156155--
157−-- /See also: 'bracket_'/
156+-- /See also: 'bracketUnsafe'/
158157--
159158-- /Inhibits stream fusion/
160159--
@@ -167,11 +166,17 @@ bracketIO bef aft = bracket3IO bef aft aft aft
167166-- the process in case of exception or garbage collection, but waits for the
168167-- process to terminate in normal cases.
169168
170−-- | Like 'bracketIO' but can use separate cleanup actions depending on the mode
171−-- of termination. @bracket3IO before onStop onGC onException action@ runs
172−-- @action@ using the result of @before@. If the stream stops, @onStop@ action
173−-- is executed, if the stream is abandoned @onGC@ is executed, if the stream
174−-- encounters an exception @onException@ is executed.
169+-- | Like 'bracketIO' but can use 3 separate cleanup actions depending on the
170+-- mode of termination:
171+--
172+-- 1. When the stream stops normally
173+-- 2. When the stream is garbage collected
174+-- 3. When the stream encounters an exception
175+--
176+-- @bracket3IO before onStop onGC onException action@ runs @action@ using the
177+-- result of @before@. If the stream stops, @onStop@ action is executed, if the
178+-- stream is abandoned @onGC@ is executed, if the stream encounters an
179+-- exception @onException@ is executed.
175180--
176181-- /Pre-release/
177182{-# INLINE bracket3IO #-}