Hoogle Search

Within LTS Haskell 24.6 (ghc-9.10.2)

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

  1. foldl' :: (a -> b -> a) -> a -> HashSet b -> a

    rio RIO.HashSet

    Reduce this set by applying a binary operator to all elements, using the given starting value (typically the left-identity of the operator). Each application of the operator is evaluated before before using the result in the next application. This function is strict in the starting value.

  2. foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b

    rio RIO.List

    Left-associative fold of a structure but with strict application of the operator. This ensures that each step of the fold is forced to Weak Head Normal Form before being applied, avoiding the collection of thunks that would otherwise occur. This is often what you want to strictly reduce a finite structure to a single strict result (e.g. sum). For a general Foldable structure this should be semantically identical to,

    foldl' f z = foldl' f z . toList
    

  3. foldl1 :: Foldable t => (a -> a -> a) -> t a -> a

    rio RIO.List.Partial

    A variant of foldl that has no base case, and thus may only be applied to non-empty structures. This function is non-total and will raise a runtime exception if the structure happens to be empty.

    foldl1 f = foldl1 f . toList
    

    Examples

    Basic usage:
    >>> foldl1 (+) [1..4]
    10
    
    >>> foldl1 (+) []
    *** Exception: Prelude.foldl1: empty list
    
    >>> foldl1 (+) Nothing
    *** Exception: foldl1: empty structure
    
    >>> foldl1 (-) [1..4]
    -8
    
    >>> foldl1 (&&) [True, False, True, True]
    False
    
    >>> foldl1 (||) [False, False, True, True]
    True
    
    >>> foldl1 (+) [1..]
    * Hangs forever *
    

  4. foldl1' :: HasCallStack => (a -> a -> a) -> [a] -> a

    rio RIO.List.Partial

    A strict version of foldl1.

  5. foldl' :: (a -> b -> a) -> a -> Map k b -> a

    rio RIO.Map

    A strict version of foldl. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.

  6. foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a

    rio RIO.Map

    Fold the keys and values in the map using the given left-associative binary operator, such that foldlWithKey f z == foldl (\z' (kx, x) -> f z' kx x) z . toAscList. For example,

    keys = reverse . foldlWithKey (\ks k x -> k:ks) []
    
    let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
    foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"
    

  7. foldlWithKey' :: (a -> k -> b -> a) -> a -> Map k b -> a

    rio RIO.Map

    A strict version of foldlWithKey. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.

  8. foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b

    rio RIO.Prelude

    Left-associative fold of a structure but with strict application of the operator. This ensures that each step of the fold is forced to Weak Head Normal Form before being applied, avoiding the collection of thunks that would otherwise occur. This is often what you want to strictly reduce a finite structure to a single strict result (e.g. sum). For a general Foldable structure this should be semantically identical to,

    foldl' f z = foldl' f z . toList
    

  9. foldlWithIndex :: (b -> Int -> a -> b) -> b -> Seq a -> b

    rio RIO.Seq

    foldlWithIndex is a version of foldl that also provides access to the index of each element.

  10. foldl' :: (a -> b -> a) -> a -> Set b -> a

    rio RIO.Set

    A strict version of foldl. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.

Page 41 of many | Previous | Next