@@ -57,9 +57,11 @@ module Streamly.Internal.Data.Fold
5757 , rollingHashFirstN
5858 -- , rollingHashLastN
5959
60+ -- ** Fold Semigroups
61+ , sconcat
62+
6063 -- ** Full Folds (Monoidal)
6164 , mconcat
62− , mconcatTo
6365 , foldMap
6466 , foldMapM
6567
@@ -610,18 +612,15 @@ rollingHashFirstN n = ltake n rollingHash
610612-- Monoidal left folds
611613------------------------------------------------------------------------------
612614
613−-- | 'mappend' the elements of an input stream to a provided starting value.
614−--
615−-- > S.fold (FL.mconcatTo 10) (S.map Sum $ S.enumerateFromTo 1 10)
615+-- | Append the elements of an input stream to a provided starting value.
616616--
617−-- This could be faster than (fmap (m0 <>) FL.mconcat) especially when we have
618−-- to perform the operation many times.
617+-- > S.fold (FL.sconcat 10) (S.map Sum $ S.enumerateFromTo 1 10)
619618--
620619-- /Internal/
621620--
622−{-# INLINE mconcatTo #-}
623−mconcatTo :: (Monad m, Monoid a) => a -> Fold m a a
624−mconcatTo i = Fold (\x a -> return $ mappend x a) (return i) return
621+{-# INLINE sconcat #-}
622+sconcat :: (Monad m, Semigroup a) => a -> Fold m a a
623+sconcat i = Fold (\x a -> return $ x <> a) (return i) return
625624
626625-- | Fold an input stream consisting of monoidal elements using 'mappend'
627626-- and 'mempty'.
@@ -631,7 +630,7 @@ mconcatTo i = Fold (\x a -> return $ mappend x a) (return i) return
631630-- @since 0.7.0
632631{-# INLINE mconcat #-}
633632mconcat :: (Monad m, Monoid a) => Fold m a a
634−mconcat = mconcatTo mempty
633+mconcat = sconcat mempty
635634
636635-- |
637636-- > foldMap f = lmap f mconcat