@@ -175,6 +175,7 @@ module Streamly.Internal.Prelude
175 , Serial.map
175 , Serial.map
176 , sequence
176 , sequence
178 -- ** Special Maps
179 -- ** Special Maps
@@ -1074,7 +1075,7 @@ foldrM = P.foldrM
1075-- > foldrM f z s = runIdentityT $ foldrS (\x xs -> lift $ f x (runIdentityT xs)) (lift z) s
1076-- > foldrM f z s = runIdentityT $ foldrS (\x xs -> lift $ f x (runIdentityT xs)) (lift z) s
1077−-- @since 0.7.0
1078+-- /Internal/
1078{-# INLINE foldrS #-}
1079{-# INLINE foldrS #-}
1079foldrS :: IsStream t => (a -> t m b -> t m b) -> t m b -> t m a -> t m b
1080foldrS :: IsStream t => (a -> t m b -> t m b) -> t m b -> t m a -> t m b
1080foldrS = K.foldrS
1081foldrS = K.foldrS
@@ -1089,7 +1090,7 @@ foldrS = K.foldrS
1089-- 'foldrT' can be used to translate streamly streams to other transformer
1090-- 'foldrT' can be used to translate streamly streams to other transformer
1090-- monads e.g. to a different streaming type.
1091-- monads e.g. to a different streaming type.
1092−-- @since 0.7.0
1093+-- /Internal/
1093{-# INLINE foldrT #-}
1094{-# INLINE foldrT #-}
1094foldrT :: (IsStream t, Monad m, Monad (s m), MonadTrans s)
1095foldrT :: (IsStream t, Monad m, Monad (s m), MonadTrans s)
1095 => (a -> s m b -> s m b) -> s m b -> t m a -> s m b
1096 => (a -> s m b -> s m b) -> s m b -> t m a -> s m b
@@ -1779,6 +1780,9 @@ x |&. f = f |$. x
1779------------------------------------------------------------------------------
1780------------------------------------------------------------------------------
1781-- | Use a 'Pipe' to transform a stream.
1782-- | Use a 'Pipe' to transform a stream.
1782{-# INLINE transform #-}
1786{-# INLINE transform #-}
1783transform :: (IsStream t, Monad m) => Pipe m a b -> t m a -> t m b
1787transform :: (IsStream t, Monad m) => Pipe m a b -> t m a -> t m b
1784transform pipe xs = fromStreamD $ D.transform pipe (toStreamD xs)
1788transform pipe xs = fromStreamD $ D.transform pipe (toStreamD xs)
@@ -1889,7 +1893,7 @@ postscanlM' step z m = fromStreamD $ D.postscanlM' step z $ toStreamD m
1890-- | Like scanl' but does not stream the final value of the accumulator.
1894-- | Like scanl' but does not stream the final value of the accumulator.
1892−-- @since 0.6.0
1896+-- /Internal/
1893{-# INLINE prescanl' #-}
1897{-# INLINE prescanl' #-}
1894prescanl' :: (IsStream t, Monad m) => (b -> a -> b) -> b -> t m a -> t m b
1898prescanl' :: (IsStream t, Monad m) => (b -> a -> b) -> b -> t m a -> t m b
1895prescanl' step z m = fromStreamD $ D.prescanl' step z $ toStreamD m
1899prescanl' step z m = fromStreamD $ D.prescanl' step z $ toStreamD m
@@ -1897,7 +1901,7 @@ prescanl' step z m = fromStreamD $ D.prescanl' step z $ toStreamD m
1897-- XXX this needs to be concurrent
1901-- XXX this needs to be concurrent
1898-- | Like postscanl' but with a monadic step function.
1902-- | Like postscanl' but with a monadic step function.
1900−-- @since 0.6.0
1904+-- /Internal/
1901{-# INLINE prescanlM' #-}
1905{-# INLINE prescanlM' #-}
1902prescanlM' :: (IsStream t, Monad m) => (b -> a -> m b) -> m b -> t m a -> t m b
1906prescanlM' :: (IsStream t, Monad m) => (b -> a -> m b) -> m b -> t m a -> t m b
1903prescanlM' step z m = fromStreamD $ D.prescanlM' step z $ toStreamD m
1907prescanlM' step z m = fromStreamD $ D.prescanlM' step z $ toStreamD m
@@ -2208,7 +2212,7 @@ reverse s = fromStreamS $ S.reverse $ toStreamS s
2209-- | Like 'reverse' but several times faster, requires a 'Storable' instance.
2213-- | Like 'reverse' but several times faster, requires a 'Storable' instance.
2211−-- @since 0.7.0
2215+-- /Internal/
2212{-# INLINE reverse' #-}
2216{-# INLINE reverse' #-}
2213reverse' :: (IsStream t, MonadIO m, Storable a) => t m a -> t m a
2217reverse' :: (IsStream t, MonadIO m, Storable a) => t m a -> t m a
2214reverse' s = fromStreamD $ D.reverse' $ toStreamD s
2218reverse' s = fromStreamD $ D.reverse' $ toStreamD s
@@ -2248,7 +2252,7 @@ intersperse a = fromStreamS . S.intersperse a . toStreamS
2249-- | Insert a monadic action after each element in the stream.
2253-- | Insert a monadic action after each element in the stream.
2251−-- @since 0.7.0
2255+-- /Internal/
2252{-# INLINE intersperseSuffix #-}
2256{-# INLINE intersperseSuffix #-}
2253intersperseSuffix :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
2257intersperseSuffix :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
2254intersperseSuffix m = fromStreamD . D.intersperseSuffix m . toStreamD
2258intersperseSuffix m = fromStreamD . D.intersperseSuffix m . toStreamD
@@ -2314,7 +2318,7 @@ intersperseBySpan _n _f _xs = undefined
2314-- "h,e,l,l,o"
2318-- "h,e,l,l,o"
2317−-- @since 0.7.0
2321+-- /Internal/
2318{-# INLINE interjectSuffix #-}
2322{-# INLINE interjectSuffix #-}
2319interjectSuffix
2323interjectSuffix
2320 :: (IsStream t, MonadAsync m)
2324 :: (IsStream t, MonadAsync m)
@@ -2573,7 +2577,7 @@ concatMap f m = fromStreamD $ D.concatMap (toStreamD . f) (toStreamD m)
2573-- but use 'concatMap' or 'concatMapWith serial' for appending @n@ streams or
2577-- but use 'concatMap' or 'concatMapWith serial' for appending @n@ streams or
2574-- infinite containers of streams.
2578-- infinite containers of streams.
2576−-- @since 0.7.0
2580+-- /Internal/
2577{-# INLINE append #-}
2581{-# INLINE append #-}
2578append ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2582append ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2579append m1 m2 = fromStreamD $ D.append (toStreamD m1) (toStreamD m2)
2583append m1 m2 = fromStreamD $ D.append (toStreamD m1) (toStreamD m2)
@@ -2600,7 +2604,7 @@ append m1 m2 = fromStreamD $ D.append (toStreamD m1) (toStreamD m2)
2601-- Do not use at scale in concatMapWith.
2605-- Do not use at scale in concatMapWith.
2603−-- @since 0.7.0
2607+-- /Internal/
2604{-# INLINE interleave #-}
2608{-# INLINE interleave #-}
2605interleave ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2609interleave ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2606interleave m1 m2 = fromStreamD $ D.interleave (toStreamD m1) (toStreamD m2)
2610interleave m1 m2 = fromStreamD $ D.interleave (toStreamD m1) (toStreamD m2)
@@ -2622,7 +2626,7 @@ interleave m1 m2 = fromStreamD $ D.interleave (toStreamD m1) (toStreamD m2)
2623-- Do not use at scale in concatMapWith.
2627-- Do not use at scale in concatMapWith.
2625−-- @since 0.7.0
2629+-- /Internal/
2626{-# INLINE interleaveSuffix #-}
2630{-# INLINE interleaveSuffix #-}
2627interleaveSuffix ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2631interleaveSuffix ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2628interleaveSuffix m1 m2 =
2632interleaveSuffix m1 m2 =
@@ -2645,7 +2649,7 @@ interleaveSuffix m1 m2 =
2646-- Do not use at scale in concatMapWith.
2650-- Do not use at scale in concatMapWith.
2648−-- @since 0.7.0
2652+-- /Internal/
2649{-# INLINE interleaveInfix #-}
2653{-# INLINE interleaveInfix #-}
2650interleaveInfix ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2654interleaveInfix ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2651interleaveInfix m1 m2 =
2655interleaveInfix m1 m2 =
@@ -2667,7 +2671,7 @@ interleaveInfix m1 m2 =
2668-- Do not use at scale in concatMapWith.
2672-- Do not use at scale in concatMapWith.
2670−-- @since 0.7.0
2674+-- /Internal/
2671{-# INLINE interleaveMin #-}
2675{-# INLINE interleaveMin #-}
2672interleaveMin ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2676interleaveMin ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2673interleaveMin m1 m2 = fromStreamD $ D.interleaveMin (toStreamD m1) (toStreamD m2)
2677interleaveMin m1 m2 = fromStreamD $ D.interleaveMin (toStreamD m1) (toStreamD m2)
@@ -2683,7 +2687,7 @@ interleaveMin m1 m2 = fromStreamD $ D.interleaveMin (toStreamD m1) (toStreamD m2
2684-- Do not use at scale in concatMapWith.
2688-- Do not use at scale in concatMapWith.
2686−-- @since 0.7.0
2690+-- /Internal/
2687{-# INLINE roundrobin #-}
2691{-# INLINE roundrobin #-}
2688roundrobin ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2692roundrobin ::(IsStream t, Monad m) => t m b -> t m b -> t m b
2689roundrobin m1 m2 = fromStreamD $ D.roundRobin (toStreamD m1) (toStreamD m2)
2693roundrobin m1 m2 = fromStreamD $ D.roundRobin (toStreamD m1) (toStreamD m2)
@@ -2719,7 +2723,7 @@ concatUnfold u m = fromStreamD $ D.concatMapU u (toStreamD m)
2719-- | Like 'concatUnfold' but interleaves the streams in the same way as
2723-- | Like 'concatUnfold' but interleaves the streams in the same way as
2720-- 'interleave' behaves instead of appending them.
2724-- 'interleave' behaves instead of appending them.
2722−-- @since 0.7.0
2726+-- /Internal/
2723{-# INLINE concatUnfoldInterleave #-}
2727{-# INLINE concatUnfoldInterleave #-}
2724concatUnfoldInterleave ::(IsStream t, Monad m)
2728concatUnfoldInterleave ::(IsStream t, Monad m)
2725 => Unfold m a b -> t m a -> t m b
2729 => Unfold m a b -> t m a -> t m b
@@ -2729,7 +2733,7 @@ concatUnfoldInterleave u m =
2729-- | Like 'concatUnfold' but executes the streams in the same way as
2733-- | Like 'concatUnfold' but executes the streams in the same way as
2730-- 'roundrobin'.
2734-- 'roundrobin'.
2732−-- @since 0.7.0
2736+-- /Internal/
2733{-# INLINE concatUnfoldRoundrobin #-}
2737{-# INLINE concatUnfoldRoundrobin #-}
2734concatUnfoldRoundrobin ::(IsStream t, Monad m)
2738concatUnfoldRoundrobin ::(IsStream t, Monad m)
2735 => Unfold m a b -> t m a -> t m b
2739 => Unfold m a b -> t m a -> t m b
@@ -2772,6 +2776,7 @@ gintercalate unf1 str1 unf2 str2 =
2772-- >>> intercalate " " UF.fromList ["abc", "def", "ghi"]
2776-- >>> intercalate " " UF.fromList ["abc", "def", "ghi"]
2773-- > "abc def ghi"
2777-- > "abc def ghi"
2775{-# INLINE intercalate #-}
2780{-# INLINE intercalate #-}
2776intercalate :: (IsStream t, Monad m)
2781intercalate :: (IsStream t, Monad m)
2777 => b -> Unfold m b c -> t m b -> t m c
2782 => b -> Unfold m b c -> t m b -> t m c
@@ -2814,6 +2819,7 @@ gintercalateSuffix unf1 str1 unf2 str2 =
2814-- >>> intercalate "\n" UF.fromList ["abc", "def", "ghi"]
2819-- >>> intercalate "\n" UF.fromList ["abc", "def", "ghi"]
2815-- > "abc\ndef\nghi\n"
2820-- > "abc\ndef\nghi\n"
2817{-# INLINE intercalateSuffix #-}
2823{-# INLINE intercalateSuffix #-}
2818intercalateSuffix :: (IsStream t, Monad m)
2824intercalateSuffix :: (IsStream t, Monad m)
2819 => b -> Unfold m b c -> t m b -> t m c
2825 => b -> Unfold m b c -> t m b -> t m c
@@ -3000,7 +3006,7 @@ concatMapTreeYieldLeavesWith combine f = concatMapLoopWith combine f yield
3000-- >>> splitAt_ 4 [1,2,3]
3006-- >>> splitAt_ 4 [1,2,3]
3001-- > ([1,2,3],[])
3007-- > ([1,2,3],[])
3003−-- @since 0.7.0
3009+-- /Internal/
3005-- This can be considered as a two-fold version of 'ltake' where we take both
3011-- This can be considered as a two-fold version of 'ltake' where we take both
3006-- the segments instead of discarding the leftover.
3012-- the segments instead of discarding the leftover.
@@ -3083,6 +3089,9 @@ chunksOf
3083 => Int -> Fold m a b -> t m a -> t m b
3089 => Int -> Fold m a b -> t m a -> t m b
3084chunksOf n f m = D.fromStreamD $ D.groupsOf n f (D.toStreamD m)
3090chunksOf n f m = D.fromStreamD $ D.groupsOf n f (D.toStreamD m)
3086{-# INLINE chunksOf2 #-}
3095{-# INLINE chunksOf2 #-}
3087chunksOf2
3096chunksOf2
3088 :: (IsStream t, Monad m)
3097 :: (IsStream t, Monad m)
@@ -3096,7 +3105,7 @@ chunksOf2 n action f m = D.fromStreamD $ D.groupsOf2 n action f (D.toStreamD m)
3097-- > arraysOf n = S.chunksOf n (A.writeN n)
3106-- > arraysOf n = S.chunksOf n (A.writeN n)
3099−-- @since 0.7.0
3108+-- /Internal/
3100{-# INLINE arraysOf #-}
3109{-# INLINE arraysOf #-}
3101arraysOf :: (IsStream t, MonadIO m, Storable a)
3110arraysOf :: (IsStream t, MonadIO m, Storable a)
3102 => Int -> t m a -> t m (Array a)
3111 => Int -> t m a -> t m (Array a)
@@ -3131,6 +3140,8 @@ intervalsOf n f xs =
3131-- long as the predicate applied to the first element of the stream and next
3140-- long as the predicate applied to the first element of the stream and next
3132-- input element holds 'True', the second group takes the rest of the input.
3141-- input element holds 'True', the second group takes the rest of the input.
3135 :: Monad m
3146 :: Monad m
3136 => (a -> a -> Bool)
3147 => (a -> a -> Bool)
@@ -3174,7 +3185,7 @@ spanBy cmp (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
3174-- >>> span_ (< 4) [1,2,3]
3185-- >>> span_ (< 4) [1,2,3]
3175-- > ([1,2,3],[])
3186-- > ([1,2,3],[])
3177−-- @since 0.7.0
3188+-- /Internal/
3179-- This can be considered as a two-fold version of 'ltakeWhile' where we take
3190-- This can be considered as a two-fold version of 'ltakeWhile' where we take
3180-- both the segments instead of discarding the leftover.
3191-- both the segments instead of discarding the leftover.
@@ -3219,7 +3230,7 @@ span p (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
3219-- >>> break_ (< 4) [3,2,1]
3230-- >>> break_ (< 4) [3,2,1]
3220-- > ([],[3,2,1])
3231-- > ([],[3,2,1])
3222−-- @since 0.7.0
3233+-- /Internal/
3223{-# INLINE break #-}
3234{-# INLINE break #-}
3225 :: Monad m
3236 :: Monad m
@@ -3231,6 +3242,8 @@ break p = span (not . p)
3232-- | Like 'spanBy' but applies the predicate in a rolling fashion i.e.
3243-- | Like 'spanBy' but applies the predicate in a rolling fashion i.e.
3233-- predicate is applied to the previous and the next input elements.
3244-- predicate is applied to the previous and the next input elements.
3234{-# INLINE spanByRolling #-}
3247{-# INLINE spanByRolling #-}
3235spanByRolling
3248spanByRolling
3236 :: Monad m
3249 :: Monad m
@@ -3589,7 +3602,7 @@ splitWithSuffix predicate f m =
3590-- > splitOn . intercalate == id
3603-- > splitOn . intercalate == id
3592−-- @since 0.7.0
3605+-- /Internal/
3594-- XXX We can use a polymorphic vector implemented by Array# to represent the
3607-- XXX We can use a polymorphic vector implemented by Array# to represent the
3595-- sequence, that way we can avoid the Storable constraint. If we still need
3608-- sequence, that way we can avoid the Storable constraint. If we still need
@@ -3643,7 +3656,7 @@ splitOnAny subseq f m = undefined -- D.fromStreamD $ D.splitOnAny f subseq (D.to
3644-- > lines = splitSuffixOn "\n"
3657-- > lines = splitSuffixOn "\n"
3646−-- @since 0.7.0
3659+-- /Internal/
3647{-# INLINE splitOnSuffixSeq #-}
3660{-# INLINE splitOnSuffixSeq #-}
3648splitOnSuffixSeq
3661splitOnSuffixSeq
3649 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
3662 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
@@ -3694,7 +3707,7 @@ wordsOn subseq f m = undefined -- D.fromStreamD $ D.wordsOn f subseq (D.toStream
3694-- >>> splitOn'_ "ll" "hello"
3707-- >>> splitOn'_ "ll" "hello"
3695-- > ["he","ll","o"]
3708-- > ["he","ll","o"]
3697−-- @since 0.7.0
3710+-- /Internal/
3698{-# INLINE splitBySeq #-}
3711{-# INLINE splitBySeq #-}
3699splitBySeq
3712splitBySeq
3700 :: (IsStream t, MonadAsync m, Storable a, Enum a, Eq a)
3713 :: (IsStream t, MonadAsync m, Storable a, Enum a, Eq a)
@@ -3730,7 +3743,7 @@ splitBySeq patt f m =
3730-- >>> splitSuffixOn'_ "." "a..b.."
3743-- >>> splitSuffixOn'_ "." "a..b.."
3731-- > ["a.",".","b.","."]
3744-- > ["a.",".","b.","."]
3733−-- @since 0.7.0
3746+-- /Internal/
3734{-# INLINE splitWithSuffixSeq #-}
3747{-# INLINE splitWithSuffixSeq #-}
3735splitWithSuffixSeq
3748splitWithSuffixSeq
3736 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
3749 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
@@ -3763,7 +3776,7 @@ splitSuffixOnAny subseq f m = undefined
3763-- CAUTION! This is not a true streaming function as the container size after
3776-- CAUTION! This is not a true streaming function as the container size after
3764-- the split and merge may not be bounded.
3777-- the split and merge may not be bounded.
3766−-- @since 0.7.0
3779+-- /Internal/
3767{-# INLINE splitInnerBy #-}
3780{-# INLINE splitInnerBy #-}
3768splitInnerBy
3781splitInnerBy
3769 :: (IsStream t, Monad m)
3782 :: (IsStream t, Monad m)
@@ -3777,7 +3790,7 @@ splitInnerBy splitter joiner xs =
3777-- | Like 'splitInnerBy' but splits assuming the separator joins the segment in
3790-- | Like 'splitInnerBy' but splits assuming the separator joins the segment in
3778-- a suffix style.
3791-- a suffix style.
3780−-- @since 0.7.0
3793+-- /Internal/
3781{-# INLINE splitInnerBySuffix #-}
3794{-# INLINE splitInnerBySuffix #-}
3782splitInnerBySuffix
3795splitInnerBySuffix
3783 :: (IsStream t, Monad m, Eq (f a), Monoid (f a))
3796 :: (IsStream t, Monad m, Eq (f a), Monoid (f a))
@@ -3898,7 +3911,7 @@ tapAsync f xs = D.fromStreamD $ D.tapAsync f (D.toStreamD xs)
3899-- Note: This may not work correctly on 32-bit machines.
3912-- Note: This may not work correctly on 32-bit machines.
3901−-- /Internal
3914+-- /Internal/
3903{-# INLINE pollCounts #-}
3916{-# INLINE pollCounts #-}
3904pollCounts ::
3917pollCounts ::
@@ -3929,7 +3942,7 @@ pollCounts predicate transf f xs =
3930-- Note: This may not work correctly on 32-bit machines.
3943-- Note: This may not work correctly on 32-bit machines.
3932−-- /Internal
3945+-- /Internal/
3933{-# INLINE tapRate #-}
3946{-# INLINE tapRate #-}
3934tapRate ::
3947tapRate ::
3935 (IsStream t, MonadAsync m, MonadCatch m)
3948 (IsStream t, MonadAsync m, MonadCatch m)