on master help sign in
Rename toFold in Tee to unTee (#2156)
commit89b95bd568bd94c472df1fbd1cbd946ead4f1e02 authorRanjeet Ranjan <ranjeetr@composewell.com> dateSat 10 Dec 2022, 09:23 (4 years ago) parent4621af7
2 files changed+9−4
core/src/Streamly/Data/Fold/Tee.hs+2−2 core/src/Streamly/Internal/Data/Fold/Tee.hs+7−2
core/src/Streamly/Data/Fold/Tee.hs+2−2
@@ -19,7 +19,7 @@
1919-- >>> import qualified Streamly.Data.Fold as Fold
2020--
2121-- >>> avg = (/) <$> (Tee Fold.sum) <*> (Tee $ fmap fromIntegral Fold.length)
22−-- >>> Stream.fold (toFold avg) $ Stream.fromList [1.0..100.0]
22+-- >>> Stream.fold (unTee avg) $ Stream.fromList [1.0..100.0]
2323-- 50.5
2424--
2525-- Similarly, the 'Semigroup' and 'Monoid' instances of 'Tee' distribute the
@@ -28,7 +28,7 @@
2828--
2929-- >>> import Data.Monoid (Sum(..))
3030-- >>> t = Tee Fold.one <> Tee Fold.latest
31−-- >>> Stream.fold (toFold t) (fmap Sum $ Stream.enumerateFromTo 1.0 100.0)
31+-- >>> Stream.fold (unTee t) (fmap Sum $ Stream.enumerateFromTo 1.0 100.0)
3232-- Just (Sum {getSum = 101.0})
3333--
3434-- The 'Num', 'Floating', and 'Fractional' instances work in the same way.
core/src/Streamly/Internal/Data/Fold/Tee.hs+7−2
@@ -11,6 +11,7 @@
1111--
1212module Streamly.Internal.Data.Fold.Tee
1313 ( Tee(..)
14+ , toFold
1415 )
1516where
1617
@@ -24,9 +25,13 @@ import qualified Streamly.Internal.Data.Fold.Type as Fold
2425-- instances.
2526--
2627newtype Tee m a b =
27− Tee { toFold :: Fold m a b }
28+ Tee { unTee :: Fold m a b }
2829 deriving (Functor)
2930
31+{-# DEPRECATED toFold "Please use 'unTee' instead." #-}
32+toFold :: Tee m a b -> Fold m a b
33+toFold = unTee
34+
3035-- | '<*>' distributes the input to both the argument 'Tee's and combines their
3136-- outputs using function application.
3237--
@@ -36,7 +41,7 @@ instance Monad m => Applicative (Tee m a) where
3641 pure a = Tee (Fold.fromPure a)
3742
3843 {-# INLINE (<*>) #-}
39− (<*>) a b = Tee (Fold.teeWith ($) (toFold a) (toFold b))
44+ (<*>) a b = Tee (Fold.teeWith ($) (unTee a) (unTee b))
4045
4146-- | '<>' distributes the input to both the argument 'Tee's and combines their
4247-- outputs using the 'Semigroup' instance of the output type.