Hoogle Search

Within LTS Haskell 24.68 (ghc-9.10.3)

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

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

    streamly-core Streamly.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}
    

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

    streamly-core Streamly.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
    

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

    streamly-core Streamly.Data.Fold

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

  4. rmapM :: Monad m => (b -> m c) -> Fold m a b -> Fold m a c

    streamly-core Streamly.Data.Fold

    Map a monadic function on the output of a fold.

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

    streamly-core Streamly.Data.Fold

    Split the input stream based on a key field and fold each split using the given fold. Useful for map/reduce, bucketizing the input in different bins or for generating histograms. Example:

    >>> import Data.Map.Strict (Map)
    
    >>> :{
    let input = Stream.fromList [("ONE",1),("ONE",1.1),("TWO",2), ("TWO",2.2)]
    classify = Fold.toMap fst (Fold.lmap snd Fold.toList)
    in Stream.fold classify input :: IO (Map String [Double])
    :}
    fromList [("ONE",[1.0,1.1]),("TWO",[2.0,2.2])]
    
    Once the classifier fold terminates for a particular key any further inputs in that bucket are ignored. Space used is proportional to the number of keys seen till now and monotonically increases because it stores whether a key has been seen or not. See demuxToMap for a more powerful version where you can use a different fold for each key. A simpler version of toMap retaining only the last value for a key can be written as:
    >>> toMap = Fold.foldl' (\kv (k, v) -> Map.insert k v kv) Map.empty
    
    Stops: never Pre-release

  6. toMapIO :: forall (m :: Type -> Type) k a b . (MonadIO m, Ord k) => (a -> k) -> Fold m a b -> Fold m a (Map k b)

    streamly-core Streamly.Data.Fold

    Same as toMap but maybe faster because it uses mutable cells as fold accumulators in the Map.

  7. lmap :: forall a b (m :: Type -> Type) r . (a -> b) -> Parser b m r -> Parser a m r

    streamly-core Streamly.Data.Parser

    lmap f parser maps the function f on the input of the parser.

    >>> Stream.parse (Parser.lmap (\x -> x * x) (Parser.fromFold Fold.sum)) (Stream.enumerateFromTo 1 100)
    Right 338350
    
    lmap = Parser.lmapM return
    

  8. lmapM :: Monad m => (a -> m b) -> Parser b m r -> Parser a m r

    streamly-core Streamly.Data.Parser

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

  9. rmapM :: Monad m => (b -> m c) -> Parser a m b -> Parser a m c

    streamly-core Streamly.Data.Parser

    rmapM f parser maps the monadic function f on the output of the parser.

    >>> rmap = fmap
    

  10. concatMap :: forall (m :: Type -> Type) a b . Monad m => (a -> Stream m b) -> Stream m a -> Stream m b

    streamly-core Streamly.Data.Stream

    Map a stream producing function on each element of the stream and then flatten the results into a single stream.

    >>> concatMap f = Stream.concatMapM (return . f)
    
    >>> concatMap f = Stream.concat . fmap f
    
    >>> concatMap f = Stream.unfoldMany (Unfold.lmap f Unfold.fromStream)
    
    See unfoldMany for a fusible alternative.

Page 1086 of many | Previous | Next