on fa417eb help sign in
84 lines 1.8 kB history raw
1-- |
2-- Module : Streamly.Internal.Data.Stream.Serial
3-- Copyright : (c) 2017 Composewell Technologies
4--
5-- License : BSD3
6-- Maintainer : streamly@composewell.com
7-- Stability : experimental
8-- Portability : GHC
9--
10-- To run examples in this module:
11--
12-- >>> import qualified Streamly.Data.Stream as Stream
13--
14module Streamly.Internal.Data.Stream.Serial
15 (
16 -- * Serial appending stream
17 SerialT
18 , Serial
19 , serial
21 -- * Construction
22 , Stream.cons
23 , Stream.consM
24 , Stream.repeat
25 , Stream.unfoldrM
26 , fromList
28 -- * Elimination
29 , toList
31 -- * Transformation
32 , map
33 , Stream.mapM
34 )
35where
37import GHC.Exts (IsList(..))
38import Streamly.Data.Stream (Stream)
40import qualified Streamly.Data.Stream as Stream
42import Prelude hiding (map)
44-- $setup
45-- >>> import qualified Streamly.Data.Stream as Stream
47------------------------------------------------------------------------------
48-- SerialT
49------------------------------------------------------------------------------
51type SerialT = Stream
53-- | A serial IO stream of elements of type @a@. See 'SerialT' documentation
54-- for more details.
55--
56-- /Since: 0.2.0 ("Streamly")/
57--
58-- @since 0.8.0
59type Serial = SerialT IO
61------------------------------------------------------------------------------
62-- Combining
63------------------------------------------------------------------------------
65{-# INLINE serial #-}
66serial :: SerialT m a -> SerialT m a -> SerialT m a
67serial = (<>)
69-- |
70-- @
71-- map = fmap
72-- @
73--
74-- Same as 'fmap'.
75--
76-- @
77-- > S.toList $ S.map (+1) $ S.fromList [1,2,3]
78-- [2,3,4]
79-- @
80--
81-- @since 0.4.0
82{-# INLINE map #-}
83map :: Monad m => (a -> b) -> SerialT m a -> SerialT m b
84map f = Stream.mapM (return . f)