Hoogle Search
Within LTS Haskell 24.4 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
data
FoldlSym2 (a6989586621680407056 :: b ~> a ~> b) (a6989586621680407057 :: b) (c :: TyFun t a b)singletons-base Prelude.Singletons No documentation available.
-
singletons-base Prelude.Singletons No documentation available.
bifoldl :: Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> crio RIO.Prelude Combines the elements of a structure in a left associative manner. Given a hypothetical function toEitherList :: p a b -> [Either a b] yielding a list of all elements of a structure in order, the following would hold:
bifoldl f g z ≡ foldl (acc -> either (f acc) (g acc)) z . toEitherList
Note that if you want an efficient left-fold, you probably want to use bifoldl' instead of bifoldl. The reason is that the latter does not force the "inner" results, resulting in a thunk chain which then must be evaluated from the outside-in.Examples
Basic usage:> bifoldl (+) (*) 3 (5, 7) 56 -- (5 + 3) * 7 > bifoldl (+) (*) 3 (7, 5) 50 -- (7 + 3) * 5 > bifoldl (+) (*) 3 (Right 5) 15 -- 5 * 3 > bifoldl (+) (*) 3 (Left 5) 8 -- 5 + 3
bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> ario RIO.Prelude As bifoldl, but strict in the result of the reduction functions at each step. This ensures that each step of the bifold 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, monolithic result (e.g., bilength).
bifoldl1 :: Bifoldable t => (a -> a -> a) -> t a a -> ario RIO.Prelude A variant of bifoldl that has no base case, and thus may only be applied to non-empty structures.
Examples
Basic usage:>>> bifoldl1 (+) (5, 7) 12
>>> bifoldl1 (+) (Right 7) 7
>>> bifoldl1 (+) (Left 5) 5
> bifoldl1 (+) (BiList [1, 2] [3, 4]) 10 -- ((1 + 2) + 3) + 4
>>> bifoldl1 (+) (BiList [1, 2] []) 3
On empty structures, this function throws an exception:>>> bifoldl1 (+) (BiList [] []) *** Exception: bifoldl1: empty structure ...
bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m ario RIO.Prelude Left associative monadic bifold over a structure.
Examples
Basic usage:>>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 ("Hello", True) "Hello" "True" 42
>>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Right True) "True" 42
>>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Left "Hello") "Hello" 42
-
rio RIO.Prelude.Types Left-associative fold operation for constructor applications. The type of gfoldl is a headache, but operationally it is a simple generalisation of a list fold. The default definition for gfoldl is const id, which is suitable for abstract datatypes with no substructures.
ifoldl :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> bdiagrams-lib Diagrams.Prelude Left-associative fold of an indexed container with access to the index i. When you don't need access to the index then foldl is more flexible in what it accepts.
foldl ≡ ifoldl . const
ifoldl' :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> bdiagrams-lib Diagrams.Prelude Fold over the elements of a structure with an index, associating to the left, but strictly. When you don't need access to the index then foldlOf' is more flexible in what it accepts.
foldl' l ≡ ifoldl' l . const
ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m bdiagrams-lib Diagrams.Prelude Monadic fold over the elements of a structure with an index, associating to the left. When you don't need access to the index then foldlM is more flexible in what it accepts.
foldlM ≡ ifoldlM . const