on 2ca80e7 help sign in
87 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
37#if __GLASGOW_HASKELL__ < 808
38import Data.Semigroup (Semigroup(..))
39#endif
40import GHC.Exts (IsList(..))
41import Streamly.Data.Stream (Stream)
43import qualified Streamly.Data.Stream as Stream
45import Prelude hiding (map)
47-- $setup
48-- >>> import qualified Streamly.Data.Stream as Stream
50------------------------------------------------------------------------------
51-- SerialT
52------------------------------------------------------------------------------
54type SerialT = Stream
56-- | A serial IO stream of elements of type @a@. See 'SerialT' documentation
57-- for more details.
58--
59-- /Since: 0.2.0 ("Streamly")/
60--
61-- @since 0.8.0
62type Serial = SerialT IO
64------------------------------------------------------------------------------
65-- Combining
66------------------------------------------------------------------------------
68{-# INLINE serial #-}
69serial :: SerialT m a -> SerialT m a -> SerialT m a
70serial = (<>)
72-- |
73-- @
74-- map = fmap
75-- @
76--
77-- Same as 'fmap'.
78--
79-- @
80-- > S.toList $ S.map (+1) $ S.fromList [1,2,3]
81-- [2,3,4]
82-- @
83--
84-- @since 0.4.0
85{-# INLINE map #-}
86map :: Monad m => (a -> b) -> SerialT m a -> SerialT m b
87map f = Stream.mapM (return . f)