on 1946eb8 help sign in
121 lines 3.1 kB history raw
1-- |
2-- Module : Streamly.Data.StreamK
3-- Copyright : (c) 2017 Composewell Technologies
4--
5-- License : BSD3
6-- Maintainer : streamly@composewell.com
7-- Stability : released
8-- Portability : GHC
9--
10-- Streams using Continuation Passing Style (CPS). See notes in "Data.Stream"
11-- module to know when to use this module.
12--
13-- 'StreamK' operations have more overhead than 'Stream' operations, however,
14-- 'Stream' operations fuse only when the pipeline is statically composed, is
15-- not too large, and does not involve recursion. For such cases, a typical
16-- example is creating a large or infinite stream by appending, 'StreamK'
17-- should be used.
18--
19-- You can use operations from "Streamly.Data.Stream" for StreamK as well by
20-- converting StreamK to Stream, and vice-versa. Most of the time converting to
21-- 'Stream' is better than using native StreamK operations, however in certain
22-- cases using native StreamK operations may work better. Using 'Stream'
23-- operations are especially when multiple contiguous operations can fuse
24-- together.
25--
26-- There are no native exception handling operations in the StreamK module,
27-- please use 'toStream' to convert to 'Stream' type and use exception
28-- handling operations from "Streamly.Data.Stream".
29--
30-- See "Streamly.Internal.Data.Stream.StreamK" for more native StreamK
31-- operations.
33-- primitive/open loop operations that can be used recursively e.g. uncons,
34-- foldBreak, parseBreak should not be converted from StreamD for use in
35-- StreamK, instead native StreamK impl should be used.
36--
37-- Closed loop operations like repeat, replicate, iterate etc can be converted
38-- from StreamD.
39--
40-- In the last phase any operation like (toStreamK . f . toStreamD) should be
41-- rewritten to a K version of f.
42-- XXX Need to add rewrite rules for all missing StreamD operations.
43--
44module Streamly.Data.StreamK
45 (
46 StreamK
48 -- * Construction
49 -- ** Primitives
50 , nil
51 , nilM
52 , cons
53 , consM
55 -- ** From Values
56 , fromPure
57 , fromEffect
59 -- ** From Stream
60 , fromStream
61 , toStream
63 -- ** From Containers
64 , fromFoldable
66 -- * Elimination
68 -- ** Primitives
69 , uncons
70 , drain
72 -- -- ** Folding
73 -- , foldBreak
75 -- ** Parsing
76 -- , parseBreak
77 , parseBreakChunks
78 , parseChunks
80 -- * Transformation
81 , mapM
82 , dropWhile
83 , take
85 -- * Combining Two Streams
86 -- ** Appending
87 , append
89 -- ** Interleaving
90 , interleave
92 -- ** Merging
93 , mergeBy
94 , mergeByM
96 -- ** Zipping
97 , zipWith
98 , zipWithM
100 -- ** Cross Product
101 -- XXX is "bind/concatFor" better to have than crossWith?
102 -- crossWith f xs1 xs2 = concatFor xs1 (\x -> fmap (f x) xs2)
103 , crossWith
104 -- , cross
105 -- , joinInner
106 -- , CrossStreamK (..)
108 -- * Stream of streams
109 , concatEffect
110 -- , concatMap
111 , concatMapWith
112 , mergeMapWith
114 -- * Buffered Operations
115 , reverse
116 , sortBy
117 )
118where
120import Streamly.Internal.Data.Stream.StreamK
121import Prelude hiding (reverse, zipWith, mapM, dropWhile, take)