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.
foldl' :: (a -> b -> a) -> a -> HashSet b -> ario 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.
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> brio 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
foldl1 :: Foldable t => (a -> a -> a) -> t a -> ario 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 *
foldl1' :: HasCallStack => (a -> a -> a) -> [a] -> ario RIO.List.Partial A strict version of foldl1.
foldl' :: (a -> b -> a) -> a -> Map k b -> ario 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.
foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> ario 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)"
foldlWithKey' :: (a -> k -> b -> a) -> a -> Map k b -> ario 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.
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> brio 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
foldlWithIndex :: (b -> Int -> a -> b) -> b -> Seq a -> brio RIO.Seq foldlWithIndex is a version of foldl that also provides access to the index of each element.
foldl' :: (a -> b -> a) -> a -> Set b -> ario 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.