on master help sign in
Add comments about unfold exception/resource mgmt ops
30f69abHarendra Kumar
core/src/Streamly/Data/Unfold.hs+5
@@ -205,6 +205,11 @@ module Streamly.Data.Unfold
205
205
206 -- ** Nesting
206 -- ** Nesting
207 , many
207 , many
208+
209+ -- Exception combinators are not exposed, we would like to encourage the
210+ -- use of Stream type instead where exception handling is required. We can
211+ -- consider exposing the unfold exception functions if there is a
212+ -- compelling use case to use unfolds instead of stream.
208 )
213 )
209where
214where
210
215
core/src/Streamly/Internal/Data/Unfold.hs+9
@@ -247,6 +247,11 @@ module Streamly.Internal.Data.Unfold
247 , bind
247 , bind
248
248
249 -- ** Resource Management
249 -- ** Resource Management
250+ -- | 'bracket' is the most general resource management operation, all other
251+ -- operations can be expressed using it. These functions have IO suffix
252+ -- because the allocation and cleanup functions are IO actions. For
253+ -- generalized allocation and cleanup functions see the functions without
254+ -- the IO suffix in the "streamly" package.
250 , gbracket_
255 , gbracket_
251 , gbracketIO
256 , gbracketIO
252 , before
257 , before
@@ -258,6 +263,10 @@ module Streamly.Internal.Data.Unfold
258 , bracket_
263 , bracket_
259
264
260 -- ** Exceptions
265 -- ** Exceptions
266+ -- | Most of these combinators inhibit stream fusion, therefore, when
267+ -- possible, they should be called in an outer loop to mitigate the cost.
268+ -- For example, instead of calling them on a stream of chars call them on a
269+ -- stream of arrays before flattening it to a stream of chars.
261 , onException
270 , onException
262 , handle
271 , handle
263 )
272 )
core/src/Streamly/Internal/FileSystem/File.hs+1−1
@@ -113,9 +113,9 @@ import Streamly.Internal.System.IO (defaultChunkSize)
113
113
114import qualified Streamly.Data.Array as A
114import qualified Streamly.Data.Array as A
115import qualified Streamly.Data.Unfold as UF
115import qualified Streamly.Data.Unfold as UF
116+import qualified Streamly.Internal.Data.Unfold as UF (bracketIO)
116import qualified Streamly.Internal.Data.Fold.Type as FL
117import qualified Streamly.Internal.Data.Fold.Type as FL
117 (Step(..), snoc, reduce)
118 (Step(..), snoc, reduce)
118−import qualified Streamly.Internal.Data.Unfold as UF (bracketIO)
119import qualified Streamly.Internal.FileSystem.Handle as FH
119import qualified Streamly.Internal.FileSystem.Handle as FH
120import qualified Streamly.Internal.Data.Stream.Chunked as AS
120import qualified Streamly.Internal.Data.Stream.Chunked as AS
121import qualified Streamly.Data.Stream as S (fold, bracketIO, mapM)
121import qualified Streamly.Data.Stream as S (fold, bracketIO, mapM)
src/Streamly/Internal/Network/Inet/TCP.hs+1−1
@@ -120,7 +120,7 @@ import qualified Network.Socket as Net
120import qualified Streamly.Data.Array as A
120import qualified Streamly.Data.Array as A
121import qualified Streamly.Data.Fold as FL
121import qualified Streamly.Data.Fold as FL
122import qualified Streamly.Data.Unfold as UF
122import qualified Streamly.Data.Unfold as UF
123−import qualified Streamly.Internal.Data.Unfold as UF (bracketIO, first)
123+import qualified Streamly.Internal.Data.Unfold as UF (first, bracketIO)
124import qualified Streamly.Internal.Data.Stream.Chunked as AS
124import qualified Streamly.Internal.Data.Stream.Chunked as AS
125import qualified Streamly.Internal.Data.Fold.Type as FL (Step(..))
125import qualified Streamly.Internal.Data.Fold.Type as FL (Step(..))
126import qualified Streamly.Internal.Data.Stream as S
126import qualified Streamly.Internal.Data.Stream as S