HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulestreamly-0.10.1Haskell2010

Streamly.Data.Fold.Tee

Deprecated. Please use Streamly.Data.Fold module from the streamly-core package.

  • 1 type
  • 1 value
  • Packagestreamly-0.10.1
  • Exports2
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTee.hs
newtypenewtype Tee (m :: Type -> Type) a b
#

Tee is a newtype wrapper over the Fold type providing distributing Applicative, Semigroup, Monoid, Num, Floating and Fractional instances.

The input received by the composed Tee is replicated and distributed to the constituent folds of the Tee.

For example, to compute the average of numbers in a stream without going through the stream twice:

Example2 expressions
avg = (/) <$> (Tee Fold.sum) <*> (Tee $ fmap fromIntegral Fold.length)Stream.fold (unTee avg) $ Stream.fromList [1.0..100.0]50.5

Similarly, the Semigroup and Monoid instances of Tee distribute the input to both the folds and combine the outputs using Monoid or Semigroup instances of the output types:

Example3 expressions
import Data.Monoid (Sum(..))t = Tee Fold.one <> Tee Fold.latestStream.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.

Constructors

Instances7Functor, Applicative, Floating, Fractional, Num, Semigroup, …
  • Functor m => Functor (Tee m a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Tee
  • Monad m => Applicative (Tee m a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Tee

    <*> distributes the input to both the argument Tees and combines their outputs using function application.

  • (Monad m, Floating b) => Floating (Tee m a b)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Tee

    Binary Floating operations distribute the input to both the argument Tees and combine their outputs using the Floating instance of the output type.

  • (Monad m, Fractional b) => Fractional (Tee m a b)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Tee

    Binary Fractional operations distribute the input to both the argument Tees and combine their outputs using the Fractional instance of the output type.

  • (Monad m, Num b) => Num (Tee m a b)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Tee

    Binary Num operations distribute the input to both the argument Tees and combine their outputs using the Num instance of the output type.

  • (Semigroup b, Monad m) => Semigroup (Tee m a b)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Tee

    <> distributes the input to both the argument Tees and combines their outputs using the Semigroup instance of the output type.

  • (Monoid b, Monad m) => Monoid (Tee m a b)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Tee

    <> distributes the input to both the argument Tees and combines their outputs using the Monoid instance of the output type.