mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Rename toFold in Tee to unTee (#2156)
This commit is contained in:
parent
4621af7bf1
commit
89b95bd568
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user