on f4de841 help sign in
86 lines 1.9 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.Internal.Data.Stream (Stream)
42import qualified Streamly.Internal.Data.Stream as Stream
44import Prelude hiding (map)
46-- $setup
47-- >>> import qualified Streamly.Data.Stream as Stream
49------------------------------------------------------------------------------
50-- SerialT
51------------------------------------------------------------------------------
53type SerialT = Stream
55-- | A serial IO stream of elements of type @a@. See 'SerialT' documentation
56-- for more details.
57--
58-- /Since: 0.2.0 ("Streamly")/
59--
60-- @since 0.8.0
61type Serial = SerialT IO
63------------------------------------------------------------------------------
64-- Combining
65------------------------------------------------------------------------------
67{-# INLINE serial #-}
68serial :: SerialT m a -> SerialT m a -> SerialT m a
69serial = (<>)
71-- |
72-- @
73-- map = fmap
74-- @
75--
76-- Same as 'fmap'.
77--
78-- @
79-- > S.toList $ S.map (+1) $ S.fromList [1,2,3]
80-- [2,3,4]
81-- @
82--
83-- @since 0.4.0
84{-# INLINE map #-}
85map :: Monad m => (a -> b) -> SerialT m a -> SerialT m b
86map f = Stream.mapM (return . f)