@@ -9,17 +9,14 @@
99
1010module StreamDOps where
1111
12−-- import Prelude
13− -- (Monad, Int, (+), ($), (.), return, fmap, even, (>), (<=),
14− -- subtract, undefined, Maybe(..))
1512import Prelude
16− (Monad, Int, (+), (.), return, (>), even, (<=),
17− Maybe(..), not)
13+ (Monad, Int, (+), ($), (.), return, (>), even, (<=),
14+ subtract, undefined, Maybe(..), not)
1815
1916import qualified Streamly.Streams.StreamD as S
2017
2118value, maxValue :: Int
22−value = 1000000
19+value = 100000
2320maxValue = value + 1000
2421
2522-------------------------------------------------------------------------------
@@ -28,34 +25,32 @@ maxValue = value + 1000
2825
2926{-# INLINE uncons #-}
3027{-# INLINE nullHeadTail #-}
31−-- {-# INLINE scan #-}
28+{-# INLINE scan #-}
3229{-# INLINE map #-}
3330{-# INLINE filterEven #-}
3431{-# INLINE filterAllOut #-}
3532{-# INLINE filterAllIn #-}
3633{-# INLINE takeOne #-}
3734{-# INLINE takeAll #-}
38−{-
3935{-# INLINE takeWhileTrue #-}
4036{-# INLINE dropAll #-}
4137{-# INLINE dropWhileTrue #-}
4238{-# INLINE zip #-}
39+{-
4340{-# INLINE concat #-}
41+-}
4442{-# INLINE composeAllInFilters #-}
4543{-# INLINE composeAllOutFilters #-}
4644{-# INLINE composeMapAllInFilter #-}
47−-}
48−uncons, nullHeadTail, map, filterEven, filterAllOut,
49− filterAllIn, takeOne, takeAll -- takeWhileTrue, dropAll, dropWhileTrue, zip,
50− -- concat, composeAllInFilters, composeAllOutFilters,
51− -- composeMapAllInFilter
45+uncons, nullHeadTail, map, scan, filterEven, filterAllOut,
46+ filterAllIn, takeOne, takeAll, takeWhileTrue, dropAll, dropWhileTrue, zip,
47+ -- concat,
48+ composeAllInFilters, composeAllOutFilters, composeMapAllInFilter
5249 :: Monad m
5350 => Stream m Int -> m ()
5451
55−{-
5652{-# INLINE composeMapM #-}
57−composeMapM :: S.MonadAsync m => Stream m Int -> m ()
58−-}
53+composeMapM :: Monad m => Stream m Int -> m ()
5954
6055{-# INLINE toList #-}
6156toList :: Monad m => Stream m Int -> m [Int]
@@ -140,7 +135,7 @@ last = S.last
140135transform :: Monad m => Stream m a -> m ()
141136transform = runStream
142137
143−-- scan = transform . S.scanl' (+) 0
138+scan = transform . S.scanlM' (\a b -> return (a + b)) 0
144139map = transform . S.map (+1)
145140mapM = transform . S.mapM return
146141filterEven = transform . S.filter even
@@ -148,7 +143,6 @@ filterAllOut = transform . S.filter (> maxValue)
148143filterAllIn = transform . S.filter (<= maxValue)
149144takeOne = transform . S.take 1
150145takeAll = transform . S.take maxValue
151−{-
152146takeWhileTrue = transform . S.takeWhile (<= maxValue)
153147dropAll = transform . S.drop maxValue
154148dropWhileTrue = transform . S.dropWhile (<= maxValue)
@@ -158,7 +152,7 @@ dropWhileTrue = transform . S.dropWhile (<= maxValue)
158152-------------------------------------------------------------------------------
159153
160154zip src = transform $ (S.zipWith (,) src src)
161−concat _n = return ()
155+-- concat _n = return ()
162156
163157-------------------------------------------------------------------------------
164158-- Composition
@@ -171,7 +165,7 @@ compose f = transform . f . f . f . f
171165composeMapM = compose (S.mapM return)
172166composeAllInFilters = compose (S.filter (<= maxValue))
173167composeAllOutFilters = compose (S.filter (> maxValue))
174−composeMapAllInFilter = compose (S.filter (<= maxValue) . fmap (subtract 1))
168+composeMapAllInFilter = compose (S.filter (<= maxValue) . S.map (subtract 1))
175169
176170{-# INLINABLE composeScaling #-}
177171composeScaling :: Monad m => Int -> Stream m Int -> m ()
@@ -183,4 +177,3 @@ composeScaling m =
183177 4 -> transform . f . f . f . f
184178 _ -> undefined
185179 where f = S.filter (<= maxValue)
186− -}