Hoogle Search

Within LTS Haskell 24.45 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. concatMap :: forall (m :: Type -> Type) b a c . Monad m => (b -> Fold m a c) -> Fold m a b -> Fold m a c

    streamly-core Streamly.Internal.Data.Fold

    Map a Fold returning function on the result of a Fold and run the returned fold. This operation can be used to express data dependencies between fold operations. Let's say the first element in the stream is a count of the following elements that we have to add, then:

    >>> import Data.Maybe (fromJust)
    
    >>> count = fmap fromJust Fold.one
    
    >>> total n = Fold.take n Fold.sum
    
    >>> Stream.fold (Fold.concatMap total count) $ Stream.fromList [10,9..1]
    45
    
    This does not fuse completely, see refold for a fusible alternative. Time: O(n^2) where n is the number of compositions. See also: foldIterateM, refold

  2. demuxKvToMap :: (Monad m, Ord k) => (k -> m (Fold m a b)) -> Fold m (k, a) (Map k b)

    streamly-core Streamly.Internal.Data.Fold

    Fold a stream of key value pairs using a function that maps keys to folds. Definition:

    >>> demuxKvToMap f = Fold.demuxToContainer fst (Fold.lmap snd . f)
    
    Example:
    >>> import Data.Map (Map)
    
    >>> :{
    let f "SUM" = return Fold.sum
    f _ = return Fold.product
    input = Stream.fromList [("SUM",1),("PRODUCT",2),("SUM",3),("PRODUCT",4)]
    in Stream.fold (Fold.demuxKvToMap f) input :: IO (Map String Int)
    :}
    fromList [("PRODUCT",8),("SUM",4)]
    
    Pre-release

  3. demuxToMap :: (Monad m, Ord k) => (a -> k) -> (a -> m (Fold m a b)) -> Fold m a (Map k b)

    streamly-core Streamly.Internal.Data.Fold

    This collects all the results of demux in a Map.

  4. demuxToMapIO :: (MonadIO m, Ord k) => (a -> k) -> (a -> m (Fold m a b)) -> Fold m a (Map k b)

    streamly-core Streamly.Internal.Data.Fold

    Same as demuxToMap but uses demuxIO for better performance.

  5. drainMapM :: Monad m => (a -> m b) -> Fold m a ()

    streamly-core Streamly.Internal.Data.Fold

    Definitions:

    >>> drainMapM f = Fold.lmapM f Fold.drain
    
    >>> drainMapM f = Fold.foldMapM (void . f)
    
    Drain all input after passing it through a monadic function. This is the dual of mapM_ on stream producers.

  6. foldMap :: forall (m :: Type -> Type) b a . (Monad m, Monoid b) => (a -> b) -> Fold m a b

    streamly-core Streamly.Internal.Data.Fold

    Definition:

    >>> foldMap f = Fold.lmap f Fold.mconcat
    
    Make a fold from a pure function that folds the output of the function using mappend and mempty.
    >>> sum = Fold.foldMap Data.Monoid.Sum
    
    >>> Stream.fold sum $ Stream.enumerateFromTo 1 10
    Sum {getSum = 55}
    

  7. foldMapM :: (Monad m, Monoid b) => (a -> m b) -> Fold m a b

    streamly-core Streamly.Internal.Data.Fold

    Definition:

    >>> foldMapM f = Fold.lmapM f Fold.mconcat
    
    Make a fold from a monadic function that folds the output of the function using mappend and mempty.
    >>> sum = Fold.foldMapM (return . Data.Monoid.Sum)
    
    >>> Stream.fold sum $ Stream.enumerateFromTo 1 10
    Sum {getSum = 55}
    

  8. kvToMap :: forall (m :: Type -> Type) k a b . (Monad m, Ord k) => Fold m a b -> Fold m (k, a) (Map k b)

    streamly-core Streamly.Internal.Data.Fold

    Given an input stream of key value pairs and a fold for values, fold all the values belonging to each key. Useful for map/reduce, bucketizing the input in different bins or for generating histograms. Definition:

    >>> kvToMap = Fold.toMap fst . Fold.lmap snd
    
    Example:
    >>> :{
    let input = Stream.fromList [("ONE",1),("ONE",1.1),("TWO",2), ("TWO",2.2)]
    in Stream.fold (Fold.kvToMap Fold.toList) input
    :}
    fromList [("ONE",[1.0,1.1]),("TWO",[2.0,2.2])]
    
    Pre-release

  9. lmap :: forall a b (m :: Type -> Type) r . (a -> b) -> Fold m b r -> Fold m a r

    streamly-core Streamly.Internal.Data.Fold

    lmap f fold maps the function f on the input of the fold. Definition:

    >>> lmap = Fold.lmapM return
    
    Example:
    >>> sumSquared = Fold.lmap (\x -> x * x) Fold.sum
    
    >>> Stream.fold sumSquared (Stream.enumerateFromTo 1 100)
    338350
    

  10. lmapM :: Monad m => (a -> m b) -> Fold m b r -> Fold m a r

    streamly-core Streamly.Internal.Data.Fold

    lmapM f fold maps the monadic function f on the input of the fold.

Page 1088 of many | Previous | Next