on master help sign in
Rename toFold in Tee to unTee (#2156)
89b95bdRanjeet Ranjan
core/src/Streamly/Data/Fold/Tee.hs+2−2
@@ -19,7 +19,7 @@
19-- >>> import qualified Streamly.Data.Fold as Fold
19-- >>> import qualified Streamly.Data.Fold as Fold
20--
20--
21-- >>> avg = (/) <$> (Tee Fold.sum) <*> (Tee $ fmap fromIntegral Fold.length)
21-- >>> 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]
23-- 50.5
23-- 50.5
24--
24--
25-- Similarly, the 'Semigroup' and 'Monoid' instances of 'Tee' distribute the
25-- Similarly, the 'Semigroup' and 'Monoid' instances of 'Tee' distribute the
@@ -28,7 +28,7 @@
28--
28--
29-- >>> import Data.Monoid (Sum(..))
29-- >>> import Data.Monoid (Sum(..))
30-- >>> t = Tee Fold.one <> Tee Fold.latest
30-- >>> 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)
32-- Just (Sum {getSum = 101.0})
32-- Just (Sum {getSum = 101.0})
33--
33--
34-- The 'Num', 'Floating', and 'Fractional' instances work in the same way.
34-- 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 @@
11--
11--
12module Streamly.Internal.Data.Fold.Tee
12module Streamly.Internal.Data.Fold.Tee
13 ( Tee(..)
13 ( Tee(..)
14+ , toFold
14 )
15 )
15where
16where
16
17
@@ -24,9 +25,13 @@ import qualified Streamly.Internal.Data.Fold.Type as Fold
24-- instances.
25-- instances.
25--
26--
26newtype Tee m a b =
27newtype Tee m a b =
27− Tee { toFold :: Fold m a b }
28+ Tee { unTee :: Fold m a b }
28 deriving (Functor)
29 deriving (Functor)
29
30
31+{-# DEPRECATED toFold "Please use 'unTee' instead." #-}
32+toFold :: Tee m a b -> Fold m a b
33+toFold = unTee
34+
30-- | '<*>' distributes the input to both the argument 'Tee's and combines their
35-- | '<*>' distributes the input to both the argument 'Tee's and combines their
31-- outputs using function application.
36-- outputs using function application.
32--
37--
@@ -36,7 +41,7 @@ instance Monad m => Applicative (Tee m a) where
36 pure a = Tee (Fold.fromPure a)
41 pure a = Tee (Fold.fromPure a)
37
42
38 {-# INLINE (<*>) #-}
43 {-# INLINE (<*>) #-}
39− (<*>) a b = Tee (Fold.teeWith ($) (toFold a) (toFold b))
44+ (<*>) a b = Tee (Fold.teeWith ($) (unTee a) (unTee b))
40
45
41-- | '<>' distributes the input to both the argument 'Tee's and combines their
46-- | '<>' distributes the input to both the argument 'Tee's and combines their
42-- outputs using the 'Semigroup' instance of the output type.
47-- outputs using the 'Semigroup' instance of the output type.