Hoogle Search
Within LTS Haskell 24.3 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> bbase 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
foldl1 :: Foldable t => (a -> a -> a) -> t a -> abase Prelude 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 *
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> bhedgehog Hedgehog.Internal.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
foldl1 :: Foldable t => (a -> a -> a) -> t a -> ahedgehog Hedgehog.Internal.Prelude 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 *
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> bghc GHC.Prelude.Basic No documentation available.
foldl1 :: Foldable t => (a -> a -> a) -> t a -> aghc GHC.Prelude.Basic No documentation available.
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
foldl1Of :: HasCallStack => Getting (Dual (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> adiagrams-lib Diagrams.Prelude A variant of foldlOf that has no base case and thus may only be applied to lenses and structures such that the Lens views at least one element of the structure.
>>> foldl1Of each (+) (1,2,3,4) 10
foldl1Of l f ≡ foldl1 f . toListOf l foldl1 ≡ foldl1Of folded
foldl1Of :: Getter s a -> (a -> a -> a) -> s -> a foldl1Of :: Fold s a -> (a -> a -> a) -> s -> a foldl1Of :: Iso' s a -> (a -> a -> a) -> s -> a foldl1Of :: Lens' s a -> (a -> a -> a) -> s -> a foldl1Of :: Traversal' s a -> (a -> a -> a) -> s -> a
foldl1Of' :: HasCallStack => Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> adiagrams-lib Diagrams.Prelude A variant of foldlOf' that has no base case and thus may only be applied to folds and structures such that the fold views at least one element of the structure.
foldl1Of' l f ≡ foldl1' f . toListOf l
foldl1Of' :: Getter s a -> (a -> a -> a) -> s -> a foldl1Of' :: Fold s a -> (a -> a -> a) -> s -> a foldl1Of' :: Iso' s a -> (a -> a -> a) -> s -> a foldl1Of' :: Lens' s a -> (a -> a -> a) -> s -> a foldl1Of' :: Traversal' s a -> (a -> a -> a) -> s -> a
foldlMOf :: Monad m => Getting (Endo (r -> m r)) s a -> (r -> a -> m r) -> r -> s -> m rdiagrams-lib Diagrams.Prelude Monadic fold over the elements of a structure, associating to the left, i.e. from left to right.
foldlM ≡ foldlMOf folded
foldlMOf :: Monad m => Getter s a -> (r -> a -> m r) -> r -> s -> m r foldlMOf :: Monad m => Fold s a -> (r -> a -> m r) -> r -> s -> m r foldlMOf :: Monad m => Iso' s a -> (r -> a -> m r) -> r -> s -> m r foldlMOf :: Monad m => Lens' s a -> (r -> a -> m r) -> r -> s -> m r foldlMOf :: Monad m => Traversal' s a -> (r -> a -> m r) -> r -> s -> m r