on master help sign in
fix streamK build and examples build
09fddfaHarendra Kumar
examples/CirclingSquare.hs+1−1
@@ -78,6 +78,6 @@ main :: IO ()
78main = do
78main = do
79 sdlInit
79 sdlInit
80 cref <- newIORef (0,0)
80 cref <- newIORef (0,0)
81− runStream $ asyncly $ constRate 40
81+ S.runStream $ asyncly $ constRate 40
82 $ S.repeatM (updateController cref)
82 $ S.repeatM (updateController cref)
83 `parallel` S.repeatM (updateDisplay cref)
83 `parallel` S.repeatM (updateDisplay cref)
src/Streamly/Streams/Prelude.hs+1−1
@@ -127,7 +127,7 @@ foldrM step acc m = S.foldrM step acc $ toStreamS m
127{-# INLINE foldrMx #-}
127{-# INLINE foldrMx #-}
128foldrMx :: (Monad m, IsStream t)
128foldrMx :: (Monad m, IsStream t)
129 => (a -> m x -> m x) -> m x -> (m x -> m b) -> t m a -> m b
129 => (a -> m x -> m x) -> m x -> (m x -> m b) -> t m a -> m b
130−foldrMx step final project m = S.foldrMx step final project $ toStreamS m
130+foldrMx step final project m = D.foldrMx step final project $ D.toStreamD m
131
131
132{-# INLINE foldr #-}
132{-# INLINE foldr #-}
133foldr :: (Monad m, IsStream t) => (a -> b -> b) -> b -> t m a -> m b
133foldr :: (Monad m, IsStream t) => (a -> b -> b) -> b -> t m a -> m b
src/Streamly/Streams/StreamK.hs+13−12
@@ -74,16 +74,17 @@ module Streamly.Streams.StreamK
74 -- * Elimination
74 -- * Elimination
75 -- ** General Folds
75 -- ** General Folds
76 , foldr
76 , foldr
77+ , foldr1
77 , foldrM
78 , foldrM
78 , foldrS
79 , foldrS
79 , foldrT
80 , foldrT
80− , foldr1
81+
81 , foldl'
82 , foldl'
82 , foldlM'
83 , foldlM'
83 , foldlS
84 , foldlS
84 , foldlT
85 , foldlT
85− , foldx'
86+ , foldlx'
86− , foldxM'
87+ , foldlMx'
87
88
88 -- ** Specialized Folds
89 -- ** Specialized Folds
89 , runStream
90 , runStream
@@ -410,10 +411,10 @@ foldr1 step m = do
410-- @foldl@ library. The suffix @x@ is a mnemonic for extraction.
411-- @foldl@ library. The suffix @x@ is a mnemonic for extraction.
411--
412--
412-- Note that the accumulator is always evaluated including the initial value.
413-- Note that the accumulator is always evaluated including the initial value.
413−{-# INLINE foldx' #-}
414+{-# INLINE foldlx' #-}
414−foldx' :: forall t m a b x. (IsStream t, Monad m)
415+foldlx' :: forall t m a b x. (IsStream t, Monad m)
415 => (x -> a -> x) -> x -> (x -> b) -> t m a -> m b
416 => (x -> a -> x) -> x -> (x -> b) -> t m a -> m b
416−foldx' step begin done m = get $ go m begin
417+foldlx' step begin done m = get $ go m begin
417 where
418 where
418 {-# NOINLINE get #-}
419 {-# NOINLINE get #-}
419 get :: t m x -> m b
420 get :: t m x -> m b
@@ -440,14 +441,14 @@ foldx' step begin done m = get $ go m begin
440-- | Strict left associative fold.
441-- | Strict left associative fold.
441{-# INLINE foldl' #-}
442{-# INLINE foldl' #-}
442foldl' :: (IsStream t, Monad m) => (b -> a -> b) -> b -> t m a -> m b
443foldl' :: (IsStream t, Monad m) => (b -> a -> b) -> b -> t m a -> m b
443−foldl' step begin = foldx' step begin id
444+foldl' step begin = foldlx' step begin id
444
445
445-- XXX replace the recursive "go" with explicit continuations.
446-- XXX replace the recursive "go" with explicit continuations.
446-- | Like 'foldx', but with a monadic step function.
447-- | Like 'foldx', but with a monadic step function.
447−{-# INLINABLE foldxM' #-}
448+{-# INLINABLE foldlMx' #-}
448−foldxM' :: (IsStream t, Monad m)
449+foldlMx' :: (IsStream t, Monad m)
449 => (x -> a -> m x) -> m x -> (x -> m b) -> t m a -> m b
450 => (x -> a -> m x) -> m x -> (x -> m b) -> t m a -> m b
450−foldxM' step begin done m = go begin m
451+foldlMx' step begin done m = go begin m
451 where
452 where
452 go !acc m1 =
453 go !acc m1 =
453 let stop = acc >>= done
454 let stop = acc >>= done
@@ -458,7 +459,7 @@ foldxM' step begin done m = go begin m
458-- | Like 'foldl'' but with a monadic step function.
459-- | Like 'foldl'' but with a monadic step function.
459{-# INLINE foldlM' #-}
460{-# INLINE foldlM' #-}
460foldlM' :: (IsStream t, Monad m) => (b -> a -> m b) -> b -> t m a -> m b
461foldlM' :: (IsStream t, Monad m) => (b -> a -> m b) -> b -> t m a -> m b
461−foldlM' step begin = foldxM' step (return begin) return
462+foldlM' step begin = foldlMx' step (return begin) return
462
463
463-- | Lazy left fold to a stream.
464-- | Lazy left fold to a stream.
464{-# INLINE foldlS #-}
465{-# INLINE foldlS #-}
@@ -584,7 +585,7 @@ any p m = go m
584-- | Extract the last element of the stream, if any.
585-- | Extract the last element of the stream, if any.
585{-# INLINE last #-}
586{-# INLINE last #-}
586last :: (IsStream t, Monad m) => t m a -> m (Maybe a)
587last :: (IsStream t, Monad m) => t m a -> m (Maybe a)
587−last = foldx' (\_ y -> Just y) Nothing id
588+last = foldlx' (\_ y -> Just y) Nothing id
588
589
589{-# INLINE minimum #-}
590{-# INLINE minimum #-}
590minimum :: (IsStream t, Monad m, Ord a) => t m a -> m (Maybe a)
591minimum :: (IsStream t, Monad m, Ord a) => t m a -> m (Maybe a)