Rename toFold in Tee to unTee (#2156)

This commit is contained in:
Ranjeet Ranjan 2022-12-10 09:23:33 +05:30 committed by GitHub
parent 4621af7bf1
commit 89b95bd568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -19,7 +19,7 @@
-- >>> import qualified Streamly.Data.Fold as Fold
--
-- >>> avg = (/) <$> (Tee Fold.sum) <*> (Tee $ fmap fromIntegral Fold.length)
-- >>> Stream.fold (toFold avg) $ Stream.fromList [1.0..100.0]
-- >>> Stream.fold (unTee avg) $ Stream.fromList [1.0..100.0]
-- 50.5
--
-- Similarly, the 'Semigroup' and 'Monoid' instances of 'Tee' distribute the
@ -28,7 +28,7 @@
--
-- >>> import Data.Monoid (Sum(..))
-- >>> t = Tee Fold.one <> Tee Fold.latest
-- >>> Stream.fold (toFold t) (fmap Sum $ Stream.enumerateFromTo 1.0 100.0)
-- >>> Stream.fold (unTee t) (fmap Sum $ Stream.enumerateFromTo 1.0 100.0)
-- Just (Sum {getSum = 101.0})
--
-- The 'Num', 'Floating', and 'Fractional' instances work in the same way.

View File

@ -11,6 +11,7 @@
--
module Streamly.Internal.Data.Fold.Tee
( Tee(..)
, toFold
)
where
@ -24,9 +25,13 @@ import qualified Streamly.Internal.Data.Fold.Type as Fold
-- instances.
--
newtype Tee m a b =
Tee { toFold :: Fold m a b }
Tee { unTee :: Fold m a b }
deriving (Functor)
{-# DEPRECATED toFold "Please use 'unTee' instead." #-}
toFold :: Tee m a b -> Fold m a b
toFold = unTee
-- | '<*>' distributes the input to both the argument 'Tee's and combines their
-- outputs using function application.
--
@ -36,7 +41,7 @@ instance Monad m => Applicative (Tee m a) where
pure a = Tee (Fold.fromPure a)
{-# INLINE (<*>) #-}
(<*>) a b = Tee (Fold.teeWith ($) (toFold a) (toFold b))
(<*>) a b = Tee (Fold.teeWith ($) (unTee a) (unTee b))
-- | '<>' distributes the input to both the argument 'Tee's and combines their
-- outputs using the 'Semigroup' instance of the output type.