relude-1.2.2.0: Safe, performant, user-friendly and lightweight Haskell Standard Library

Copyright | (c) 2018-2023 Kowainik
License | MIT
Maintainer | Kowainik <xrom.xkov@gmail.com>
Stability | Stable
Portability | Portable
Safe Haskell | Safe
Language | Haskell2010

Relude.Foldable.Reexport

Contents

- `Foldable` reexports
- `Bi` reexports

Description

Reexports Data.Foldable and Data.Traversable.

Synopsis

- class Foldable (t :: Type -> Type) where
  - fold :: Monoid m => t m -> m
  - foldMap :: Monoid m => (a -> m) -> t a -> m
  - foldMap' :: Monoid m => (a -> m) -> t a -> m
  - foldr :: (a -> b -> b) -> b -> t a -> b
  - foldl' :: (b -> a -> b) -> b -> t a -> b
  - toList :: t a -> [a]
  - null :: t a -> Bool
  - length :: t a -> Int
- concat :: Foldable t => t [a] -> [a]
- and :: Foldable t => t Bool -> Bool
- or :: Foldable t => t Bool -> Bool
- any :: Foldable t => (a -> Bool) -> t a -> Bool
- all :: Foldable t => (a -> Bool) -> t a -> Bool
- concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
- foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
- traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
- for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
- mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
- forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
- sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()
- sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
- asum :: (Foldable t, Alternative f) => t (f a) -> f a
- find :: Foldable t => (a -> Bool) -> t a -> Maybe a
- class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
  - traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
  - sequenceA :: Applicative f => t (f a) -> f (t a)
  - mapM :: Monad m => (a -> m b) -> t a -> m (t b)
  - sequence :: Monad m => t (m a) -> m (t a)
- forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
- mapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
- mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
- class Bifoldable (p :: Type -> Type -> Type) where
  - bifold :: Monoid m => p m m -> m
  - bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> p a b -> m
  - bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c
  - bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c
- bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c
- bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c
- bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a
- bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a
- bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f ()
- bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f ()
- bisequence_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f ()
- biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a
- biList :: Bifoldable t => t a a -> [a]
- binull :: Bifoldable t => t a b -> Bool
- bilength :: Bifoldable t => t a b -> Int
- bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool
- biand :: Bifoldable t => t Bool Bool -> Bool
- bior :: Bifoldable t => t Bool Bool -> Bool
- biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool
- biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool
- bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a
- class (Bifunctor t, Bifoldable t) => Bitraversable (t :: Type -> Type -> Type) where
  - bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
- bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)
- bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)
- bimapDefault :: Bitraversable t => (a -> b) -> (c -> d) -> t a c -> t b d
- bifoldMapDefault :: (Bitraversable t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m

# `Foldable` reexports

class Foldable (t :: Type -> Type) where #

The Foldable class represents data structures that can be reduced to a summary value one element at a time. Strict left-associative folds are a good fit for space-efficient reduction, while lazy right-associative folds are a good fit for corecursive iteration, or for folds that short-circuit after processing an initial subsequence of the structure's elements.

Instances can be derived automatically by enabling the `DeriveFoldable` extension. For example, a derived instance for a binary tree might be:

    {-# LANGUAGE DeriveFoldable #-}
    data Tree a = Empty
                | Leaf a
                | Node (Tree a) a (Tree a)
        deriving Foldable

A more detailed description can be found in the Overview section of Data.Foldable.

For the class laws see the Laws section of Data.Foldable.

Minimal complete definition

foldMap | foldr

Methods

fold :: Monoid m => t m -> m #

Given a structure with elements whose type is a `Monoid`, combine them via the monoid's `(`<>`)` operator. This fold is right-associative and lazy in the accumulator. When you need a strict left-associative fold, use `foldMap'` instead, with `id` as the map.

#### Examples

Expand

Basic usage:

    >>> fold [[1, 2, 3], [4, 5], [6], []]
    [1,2,3,4,5,6]

    >>> fold $ Node (Leaf (Sum 1)) (Sum 3) (Leaf (Sum 5))
    Sum {getSum = 9}

Folds of unbounded structures do not terminate when the monoid's `(`<>`)` operator is strict:

    >>> fold (repeat Nothing)
    * Hangs forever *

Lazy corecursive folds of unbounded structures are fine:

    >>> take 12 $ fold $ map (\i -> [i..i+2]) [0..]
    [0,1,2,1,2,3,2,3,4,3,4,5]
    >>> sum $ take 4000000 $ fold $ map (\i -> [i..i+2]) [0..]
    2666668666666

foldMap :: Monoid m => (a -> m) -> t a -> m #

Map each element of the structure into a monoid, and combine the results with `(`<>`)`. This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider `foldMap'` instead.

#### Examples

Expand

Basic usage:

    >>> foldMap Sum [1, 3, 5]
    Sum {getSum = 9}

    >>> foldMap Product [1, 3, 5]
    Product {getProduct = 15}

    >>> foldMap (replicate 3) [1, 2, 3]
    [1,1,1,2,2,2,3,3,3]

When a Monoid's `(`<>`)` is lazy in its second argument, `foldMap` can return a result even from an unbounded structure. For example, lazy accumulation enables Data.ByteString.Builder to efficiently serialise large data structures and produce the output incrementally:

    >>> import qualified Data.ByteString.Lazy as L
    >>> import qualified Data.ByteString.Builder as B
    >>> let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20
    >>> let lbs = B.toLazyByteString $ foldMap bld [0..]
    >>> L.take 64 lbs
    "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"

foldMap' :: Monoid m => (a -> m) -> t a -> m #

A left-associative variant of `foldMap` that is strict in the accumulator. Use this method for strict reduction when partial results are merged via `(`<>`)`.

#### Examples

Expand

Define a `Monoid` over finite bit strings under `xor`. Use it to strictly compute the `xor` of a list of `Int` values.

    >>> :set -XGeneralizedNewtypeDeriving
    >>> import Data.Bits (Bits, FiniteBits, xor, zeroBits)
    >>> import Data.Foldable (foldMap')
    >>> import Numeric (showHex)
    >>>
    >>> newtype X a = X a deriving (Eq, Bounded, Enum, Bits, FiniteBits)
    >>> instance Bits a => Semigroup (X a) where X a <> X b = X (a `xor` b)
    >>> instance Bits a => Monoid    (X a) where mempty     = X zeroBits
    >>>
    >>> let bits :: [Int]; bits = [0xcafe, 0xfeed, 0xdeaf, 0xbeef, 0x5411]
    >>> (\ (X a) -> showString "0x" . showHex a $ "") $ foldMap' X bits
    "0x42"

@since base-4.13.0.0

foldr :: (a -> b -> b) -> b -> t a -> b #

Right-associative fold of a structure, lazy in the accumulator.

In the case of lists, `foldr`, when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left:

    foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)

Note that since the head of the resulting expression is produced by an application of the operator to the first element of the list, given an operator lazy in its right argument, `foldr` can produce a terminating expression from an unbounded list.

For a general `Foldable` structure this should be semantically identical to,

    foldr f z = foldr f z . toList

#### Examples

Expand

Basic usage:

    >>> foldr (||) False [False, True, False]
    True

    >>> foldr (||) False []
    False

    >>> foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd']
    "foodcba"

##### Infinite structures

⚠️ Applying `foldr` to infinite structures usually doesn't terminate.

It may still terminate under one of the following conditions:

- the folding function is short-circuiting
- the folding function is lazy on its second argument

###### Short-circuiting

`(`||`)` short-circuits on `True` values, so the following terminates because there is a `True` value finitely far from the left side:

    >>> foldr (||) False (True : repeat False)
    True

But the following doesn't terminate:

    >>> foldr (||) False (repeat False ++ [True])
    * Hangs forever *

###### Laziness in the second argument

Applying `foldr` to infinite structures terminates when the operator is lazy in its second argument (the initial accumulator is never used in this case, and so could be left `undefined`, but `[]` is more clear):

    >>> take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1)
    [1,4,7,10,13]

foldl' :: (b -> a -> b) -> b -> t a -> b #

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

@since base-4.6.0.0

toList :: t a -> [a] #

List of elements of a structure, from left to right. If the entire list is intended to be reduced via a fold, just fold the structure directly bypassing the list.

#### Examples

Expand

Basic usage:

    >>> toList Nothing
    []

    >>> toList (Just 42)
    [42]

    >>> toList (Left "foo")
    []

    >>> toList (Node (Leaf 5) 17 (Node Empty 12 (Leaf 8)))
    [5,17,12,8]

For lists, `toList` is the identity:

    >>> toList [1, 2, 3]
    [1,2,3]

@since base-4.8.0.0

null :: t a -> Bool #

Test whether the structure is empty. The default implementation is Left-associative and lazy in both the initial element and the accumulator. Thus optimised for structures where the first element can be accessed in constant time. Structures where this is not the case should have a non-default implementation.

#### Examples

Expand

Basic usage:

    >>> null []
    True

    >>> null [1]
    False

`null` is expected to terminate even for infinite structures. The default implementation terminates provided the structure is bounded on the left (there is a leftmost element).

    >>> null [1..]
    False

@since base-4.8.0.0

length :: t a -> Int #

Returns the size/length of a finite structure as an `Int`. The default implementation just counts elements starting with the leftmost. Instances for structures that can compute the element count faster than via element-by-element counting, should provide a specialised implementation.

#### Examples

Expand

Basic usage:

    >>> length []
    0

    >>> length ['a', 'b', 'c']
    3
    >>> length [1..]
    * Hangs forever *

@since base-4.8.0.0

#### Instances

Instances details

Foldable Complex | Since: base-4.9.0.0
Instance details Defined in Data.Complex Methods fold :: Monoid m => Complex m -> m # foldMap :: Monoid m => (a -> m) -> Complex a -> m # foldMap' :: Monoid m => (a -> m) -> Complex a -> m # foldr :: (a -> b -> b) -> b -> Complex a -> b # foldr' :: (a -> b -> b) -> b -> Complex a -> b # foldl :: (b -> a -> b) -> b -> Complex a -> b # foldl' :: (b -> a -> b) -> b -> Complex a -> b # foldr1 :: (a -> a -> a) -> Complex a -> a # foldl1 :: (a -> a -> a) -> Complex a -> a # toList :: Complex a -> [a] # null :: Complex a -> Bool # length :: Complex a -> Int # elem :: Eq a => a -> Complex a -> Bool # maximum :: Ord a => Complex a -> a # minimum :: Ord a => Complex a -> a # sum :: Num a => Complex a -> a # product :: Num a => Complex a -> a #
Foldable First | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldMap' :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # toList :: First a -> [a] # null :: First a -> Bool # length :: First a -> Int # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # sum :: Num a => First a -> a # product :: Num a => First a -> a #
Foldable Last | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldMap' :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # toList :: Last a -> [a] # null :: Last a -> Bool # length :: Last a -> Int # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # minimum :: Ord a => Last a -> a # sum :: Num a => Last a -> a # product :: Num a => Last a -> a #
Foldable Max | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fold :: Monoid m => Max m -> m # foldMap :: Monoid m => (a -> m) -> Max a -> m # foldMap' :: Monoid m => (a -> m) -> Max a -> m # foldr :: (a -> b -> b) -> b -> Max a -> b # foldr' :: (a -> b -> b) -> b -> Max a -> b # foldl :: (b -> a -> b) -> b -> Max a -> b # foldl' :: (b -> a -> b) -> b -> Max a -> b # foldr1 :: (a -> a -> a) -> Max a -> a # foldl1 :: (a -> a -> a) -> Max a -> a # toList :: Max a -> [a] # null :: Max a -> Bool # length :: Max a -> Int # elem :: Eq a => a -> Max a -> Bool # maximum :: Ord a => Max a -> a # minimum :: Ord a => Max a -> a # sum :: Num a => Max a -> a # product :: Num a => Max a -> a #
Foldable Min | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fold :: Monoid m => Min m -> m # foldMap :: Monoid m => (a -> m) -> Min a -> m # foldMap' :: Monoid m => (a -> m) -> Min a -> m # foldr :: (a -> b -> b) -> b -> Min a -> b # foldr' :: (a -> b -> b) -> b -> Min a -> b # foldl :: (b -> a -> b) -> b -> Min a -> b # foldl' :: (b -> a -> b) -> b -> Min a -> b # foldr1 :: (a -> a -> a) -> Min a -> a # foldl1 :: (a -> a -> a) -> Min a -> a # toList :: Min a -> [a] # null :: Min a -> Bool # length :: Min a -> Int # elem :: Eq a => a -> Min a -> Bool # maximum :: Ord a => Min a -> a # minimum :: Ord a => Min a -> a # sum :: Num a => Min a -> a # product :: Num a => Min a -> a #
Foldable SCC | Since: containers-0.5.9
Instance details Defined in Data.Graph Methods fold :: Monoid m => SCC m -> m # foldMap :: Monoid m => (a -> m) -> SCC a -> m # foldMap' :: Monoid m => (a -> m) -> SCC a -> m # foldr :: (a -> b -> b) -> b -> SCC a -> b # foldr' :: (a -> b -> b) -> b -> SCC a -> b # foldl :: (b -> a -> b) -> b -> SCC a -> b # foldl' :: (b -> a -> b) -> b -> SCC a -> b # foldr1 :: (a -> a -> a) -> SCC a -> a # foldl1 :: (a -> a -> a) -> SCC a -> a # toList :: SCC a -> [a] # null :: SCC a -> Bool # length :: SCC a -> Int # elem :: Eq a => a -> SCC a -> Bool # maximum :: Ord a => SCC a -> a # minimum :: Ord a => SCC a -> a # sum :: Num a => SCC a -> a # product :: Num a => SCC a -> a #
Foldable IntMap | Folds in order of increasing key.
Instance details Defined in Data.IntMap.Internal Methods fold :: Monoid m => IntMap m -> m # foldMap :: Monoid m => (a -> m) -> IntMap a -> m # foldMap' :: Monoid m => (a -> m) -> IntMap a -> m # foldr :: (a -> b -> b) -> b -> IntMap a -> b # foldr' :: (a -> b -> b) -> b -> IntMap a -> b # foldl :: (b -> a -> b) -> b -> IntMap a -> b # foldl' :: (b -> a -> b) -> b -> IntMap a -> b # foldr1 :: (a -> a -> a) -> IntMap a -> a # foldl1 :: (a -> a -> a) -> IntMap a -> a # toList :: IntMap a -> [a] # null :: IntMap a -> Bool # length :: IntMap a -> Int # elem :: Eq a => a -> IntMap a -> Bool # maximum :: Ord a => IntMap a -> a # minimum :: Ord a => IntMap a -> a # sum :: Num a => IntMap a -> a # product :: Num a => IntMap a -> a #
Foldable Digit |
Instance details Defined in Data.Sequence.Internal Methods fold :: Monoid m => Digit m -> m # foldMap :: Monoid m => (a -> m) -> Digit a -> m # foldMap' :: Monoid m => (a -> m) -> Digit a -> m # foldr :: (a -> b -> b) -> b -> Digit a -> b # foldr' :: (a -> b -> b) -> b -> Digit a -> b # foldl :: (b -> a -> b) -> b -> Digit a -> b # foldl' :: (b -> a -> b) -> b -> Digit a -> b # foldr1 :: (a -> a -> a) -> Digit a -> a # foldl1 :: (a -> a -> a) -> Digit a -> a # toList :: Digit a -> [a] # null :: Digit a -> Bool # length :: Digit a -> Int # elem :: Eq a => a -> Digit a -> Bool # maximum :: Ord a => Digit a -> a # minimum :: Ord a => Digit a -> a # sum :: Num a => Digit a -> a # product :: Num a => Digit a -> a #
Foldable Elem |
Instance details Defined in Data.Sequence.Internal Methods fold :: Monoid m => Elem m -> m # foldMap :: Monoid m => (a -> m) -> Elem a -> m # foldMap' :: Monoid m => (a -> m) -> Elem a -> m # foldr :: (a -> b -> b) -> b -> Elem a -> b # foldr' :: (a -> b -> b) -> b -> Elem a -> b # foldl :: (b -> a -> b) -> b -> Elem a -> b # foldl' :: (b -> a -> b) -> b -> Elem a -> b # foldr1 :: (a -> a -> a) -> Elem a -> a # foldl1 :: (a -> a -> a) -> Elem a -> a # toList :: Elem a -> [a] # null :: Elem a -> Bool # length :: Elem a -> Int # elem :: Eq a => a -> Elem a -> Bool # maximum :: Ord a => Elem a -> a # minimum :: Ord a => Elem a -> a # sum :: Num a => Elem a -> a # product :: Num a => Elem a -> a #
Foldable FingerTree |
Instance details Defined in Data.Sequence.Internal Methods fold :: Monoid m => FingerTree m -> m # foldMap :: Monoid m => (a -> m) -> FingerTree a -> m # foldMap' :: Monoid m => (a -> m) -> FingerTree a -> m # foldr :: (a -> b -> b) -> b -> FingerTree a -> b # foldr' :: (a -> b -> b) -> b -> FingerTree a -> b # foldl :: (b -> a -> b) -> b -> FingerTree a -> b # foldl' :: (b -> a -> b) -> b -> FingerTree a -> b # foldr1 :: (a -> a -> a) -> FingerTree a -> a # foldl1 :: (a -> a -> a) -> FingerTree a -> a # toList :: FingerTree a -> [a] # null :: FingerTree a -> Bool # length :: FingerTree a -> Int # elem :: Eq a => a -> FingerTree a -> Bool # maximum :: Ord a => FingerTree a -> a # minimum :: Ord a => FingerTree a -> a # sum :: Num a => FingerTree a -> a # product :: Num a => FingerTree a -> a #
Foldable Node |
Instance details Defined in Data.Sequence.Internal Methods fold :: Monoid m => Node m -> m # foldMap :: Monoid m => (a -> m) -> Node a -> m # foldMap' :: Monoid m => (a -> m) -> Node a -> m # foldr :: (a -> b -> b) -> b -> Node a -> b # foldr' :: (a -> b -> b) -> b -> Node a -> b # foldl :: (b -> a -> b) -> b -> Node a -> b # foldl' :: (b -> a -> b) -> b -> Node a -> b # foldr1 :: (a -> a -> a) -> Node a -> a # foldl1 :: (a -> a -> a) -> Node a -> a # toList :: Node a -> [a] # null :: Node a -> Bool # length :: Node a -> Int # elem :: Eq a => a -> Node a -> Bool # maximum :: Ord a => Node a -> a # minimum :: Ord a => Node a -> a # sum :: Num a => Node a -> a # product :: Num a => Node a -> a #
Foldable Seq |
Instance details Defined in Data.Sequence.Internal Methods fold :: Monoid m => Seq m -> m # foldMap :: Monoid m => (a -> m) -> Seq a -> m # foldMap' :: Monoid m => (a -> m) -> Seq a -> m # foldr :: (a -> b -> b) -> b -> Seq a -> b # foldr' :: (a -> b -> b) -> b -> Seq a -> b # foldl :: (b -> a -> b) -> b -> Seq a -> b # foldl' :: (b -> a -> b) -> b -> Seq a -> b # foldr1 :: (a -> a -> a) -> Seq a -> a # foldl1 :: (a -> a -> a) -> Seq a -> a # toList :: Seq a -> [a] # null :: Seq a -> Bool # length :: Seq a -> Int # elem :: Eq a => a -> Seq a -> Bool # maximum :: Ord a => Seq a -> a # minimum :: Ord a => Seq a -> a # sum :: Num a => Seq a -> a # product :: Num a => Seq a -> a #
Foldable ViewL |
Instance details Defined in Data.Sequence.Internal Methods fold :: Monoid m => ViewL m -> m # foldMap :: Monoid m => (a -> m) -> ViewL a -> m # foldMap' :: Monoid m => (a -> m) -> ViewL a -> m # foldr :: (a -> b -> b) -> b -> ViewL a -> b # foldr' :: (a -> b -> b) -> b -> ViewL a -> b # foldl :: (b -> a -> b) -> b -> ViewL a -> b # foldl' :: (b -> a -> b) -> b -> ViewL a -> b # foldr1 :: (a -> a -> a) -> ViewL a -> a # foldl1 :: (a -> a -> a) -> ViewL a -> a # toList :: ViewL a -> [a] # null :: ViewL a -> Bool # length :: ViewL a -> Int # elem :: Eq a => a -> ViewL a -> Bool # maximum :: Ord a => ViewL a -> a # minimum :: Ord a => ViewL a -> a # sum :: Num a => ViewL a -> a # product :: Num a => ViewL a -> a #
Foldable ViewR |
Instance details Defined in Data.Sequence.Internal Methods fold :: Monoid m => ViewR m -> m # foldMap :: Monoid m => (a -> m) -> ViewR a -> m # foldMap' :: Monoid m => (a -> m) -> ViewR a -> m # foldr :: (a -> b -> b) -> b -> ViewR a -> b # foldr' :: (a -> b -> b) -> b -> ViewR a -> b # foldl :: (b -> a -> b) -> b -> ViewR a -> b # foldl' :: (b -> a -> b) -> b -> ViewR a -> b # foldr1 :: (a -> a -> a) -> ViewR a -> a # foldl1 :: (a -> a -> a) -> ViewR a -> a # toList :: ViewR a -> [a] # null :: ViewR a -> Bool # length :: ViewR a -> Int # elem :: Eq a => a -> ViewR a -> Bool # maximum :: Ord a => ViewR a -> a # minimum :: Ord a => ViewR a -> a # sum :: Num a => ViewR a -> a # product :: Num a => ViewR a -> a #
Foldable Set | Folds in order of increasing key.
Instance details Defined in Data.Set.Internal Methods fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldMap' :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # toList :: Set a -> [a] # null :: Set a -> Bool # length :: Set a -> Int # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # minimum :: Ord a => Set a -> a # sum :: Num a => Set a -> a # product :: Num a => Set a -> a #
Foldable Tree | Folds in preorder
Instance details Defined in Data.Tree Methods fold :: Monoid m => Tree m -> m # foldMap :: Monoid m => (a -> m) -> Tree a -> m # foldMap' :: Monoid m => (a -> m) -> Tree a -> m # foldr :: (a -> b -> b) -> b -> Tree a -> b # foldr' :: (a -> b -> b) -> b -> Tree a -> b # foldl :: (b -> a -> b) -> b -> Tree a -> b # foldl' :: (b -> a -> b) -> b -> Tree a -> b # foldr1 :: (a -> a -> a) -> Tree a -> a # foldl1 :: (a -> a -> a) -> Tree a -> a # toList :: Tree a -> [a] # null :: Tree a -> Bool # length :: Tree a -> Int # elem :: Eq a => a -> Tree a -> Bool # maximum :: Ord a => Tree a -> a # minimum :: Ord a => Tree a -> a # sum :: Num a => Tree a -> a # product :: Num a => Tree a -> a #
Foldable NonEmpty | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => NonEmpty m -> m # foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m # foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m # foldr :: (a -> b -> b) -> b -> NonEmpty a -> b # foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b # foldl :: (b -> a -> b) -> b -> NonEmpty a -> b # foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b # foldr1 :: (a -> a -> a) -> NonEmpty a -> a # foldl1 :: (a -> a -> a) -> NonEmpty a -> a # toList :: NonEmpty a -> [a] # null :: NonEmpty a -> Bool # length :: NonEmpty a -> Int # elem :: Eq a => a -> NonEmpty a -> Bool # maximum :: Ord a => NonEmpty a -> a # minimum :: Ord a => NonEmpty a -> a # sum :: Num a => NonEmpty a -> a # product :: Num a => NonEmpty a -> a #
Foldable Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods fold :: Monoid m => Identity m -> m # foldMap :: Monoid m => (a -> m) -> Identity a -> m # foldMap' :: Monoid m => (a -> m) -> Identity a -> m # foldr :: (a -> b -> b) -> b -> Identity a -> b # foldr' :: (a -> b -> b) -> b -> Identity a -> b # foldl :: (b -> a -> b) -> b -> Identity a -> b # foldl' :: (b -> a -> b) -> b -> Identity a -> b # foldr1 :: (a -> a -> a) -> Identity a -> a # foldl1 :: (a -> a -> a) -> Identity a -> a # toList :: Identity a -> [a] # null :: Identity a -> Bool # length :: Identity a -> Int # elem :: Eq a => a -> Identity a -> Bool # maximum :: Ord a => Identity a -> a # minimum :: Ord a => Identity a -> a # sum :: Num a => Identity a -> a # product :: Num a => Identity a -> a #
Foldable First | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldMap' :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # toList :: First a -> [a] # null :: First a -> Bool # length :: First a -> Int # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # sum :: Num a => First a -> a # product :: Num a => First a -> a #
Foldable Last | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldMap' :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # toList :: Last a -> [a] # null :: Last a -> Bool # length :: Last a -> Int # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # minimum :: Ord a => Last a -> a # sum :: Num a => Last a -> a # product :: Num a => Last a -> a #
Foldable Down | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Down m -> m # foldMap :: Monoid m => (a -> m) -> Down a -> m # foldMap' :: Monoid m => (a -> m) -> Down a -> m # foldr :: (a -> b -> b) -> b -> Down a -> b # foldr' :: (a -> b -> b) -> b -> Down a -> b # foldl :: (b -> a -> b) -> b -> Down a -> b # foldl' :: (b -> a -> b) -> b -> Down a -> b # foldr1 :: (a -> a -> a) -> Down a -> a # foldl1 :: (a -> a -> a) -> Down a -> a # toList :: Down a -> [a] # null :: Down a -> Bool # length :: Down a -> Int # elem :: Eq a => a -> Down a -> Bool # maximum :: Ord a => Down a -> a # minimum :: Ord a => Down a -> a # sum :: Num a => Down a -> a # product :: Num a => Down a -> a #
Foldable Dual | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Dual m -> m # foldMap :: Monoid m => (a -> m) -> Dual a -> m # foldMap' :: Monoid m => (a -> m) -> Dual a -> m # foldr :: (a -> b -> b) -> b -> Dual a -> b # foldr' :: (a -> b -> b) -> b -> Dual a -> b # foldl :: (b -> a -> b) -> b -> Dual a -> b # foldl' :: (b -> a -> b) -> b -> Dual a -> b # foldr1 :: (a -> a -> a) -> Dual a -> a # foldl1 :: (a -> a -> a) -> Dual a -> a # toList :: Dual a -> [a] # null :: Dual a -> Bool # length :: Dual a -> Int # elem :: Eq a => a -> Dual a -> Bool # maximum :: Ord a => Dual a -> a # minimum :: Ord a => Dual a -> a # sum :: Num a => Dual a -> a # product :: Num a => Dual a -> a #
Foldable Product | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Product m -> m # foldMap :: Monoid m => (a -> m) -> Product a -> m # foldMap' :: Monoid m => (a -> m) -> Product a -> m # foldr :: (a -> b -> b) -> b -> Product a -> b # foldr' :: (a -> b -> b) -> b -> Product a -> b # foldl :: (b -> a -> b) -> b -> Product a -> b # foldl' :: (b -> a -> b) -> b -> Product a -> b # foldr1 :: (a -> a -> a) -> Product a -> a # foldl1 :: (a -> a -> a) -> Product a -> a # toList :: Product a -> [a] # null :: Product a -> Bool # length :: Product a -> Int # elem :: Eq a => a -> Product a -> Bool # maximum :: Ord a => Product a -> a # minimum :: Ord a => Product a -> a # sum :: Num a => Product a -> a # product :: Num a => Product a -> a #
Foldable Sum | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Sum m -> m # foldMap :: Monoid m => (a -> m) -> Sum a -> m # foldMap' :: Monoid m => (a -> m) -> Sum a -> m # foldr :: (a -> b -> b) -> b -> Sum a -> b # foldr' :: (a -> b -> b) -> b -> Sum a -> b # foldl :: (b -> a -> b) -> b -> Sum a -> b # foldl' :: (b -> a -> b) -> b -> Sum a -> b # foldr1 :: (a -> a -> a) -> Sum a -> a # foldl1 :: (a -> a -> a) -> Sum a -> a # toList :: Sum a -> [a] # null :: Sum a -> Bool # length :: Sum a -> Int # elem :: Eq a => a -> Sum a -> Bool # maximum :: Ord a => Sum a -> a # minimum :: Ord a => Sum a -> a # sum :: Num a => Sum a -> a # product :: Num a => Sum a -> a #
Foldable ZipList | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Functor.ZipList Methods fold :: Monoid m => ZipList m -> m # foldMap :: Monoid m => (a -> m) -> ZipList a -> m # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m # foldr :: (a -> b -> b) -> b -> ZipList a -> b # foldr' :: (a -> b -> b) -> b -> ZipList a -> b # foldl :: (b -> a -> b) -> b -> ZipList a -> b # foldl' :: (b -> a -> b) -> b -> ZipList a -> b # foldr1 :: (a -> a -> a) -> ZipList a -> a # foldl1 :: (a -> a -> a) -> ZipList a -> a # toList :: ZipList a -> [a] # null :: ZipList a -> Bool # length :: ZipList a -> Int # elem :: Eq a => a -> ZipList a -> Bool # maximum :: Ord a => ZipList a -> a # minimum :: Ord a => ZipList a -> a # sum :: Num a => ZipList a -> a # product :: Num a => ZipList a -> a #
Foldable Par1 | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Par1 m -> m # foldMap :: Monoid m => (a -> m) -> Par1 a -> m # foldMap' :: Monoid m => (a -> m) -> Par1 a -> m # foldr :: (a -> b -> b) -> b -> Par1 a -> b # foldr' :: (a -> b -> b) -> b -> Par1 a -> b # foldl :: (b -> a -> b) -> b -> Par1 a -> b # foldl' :: (b -> a -> b) -> b -> Par1 a -> b # foldr1 :: (a -> a -> a) -> Par1 a -> a # foldl1 :: (a -> a -> a) -> Par1 a -> a # toList :: Par1 a -> [a] # null :: Par1 a -> Bool # length :: Par1 a -> Int # elem :: Eq a => a -> Par1 a -> Bool # maximum :: Ord a => Par1 a -> a # minimum :: Ord a => Par1 a -> a # sum :: Num a => Par1 a -> a # product :: Num a => Par1 a -> a #
Foldable Hashed |
Instance details Defined in Data.Hashable.Class Methods fold :: Monoid m => Hashed m -> m # foldMap :: Monoid m => (a -> m) -> Hashed a -> m # foldMap' :: Monoid m => (a -> m) -> Hashed a -> m # foldr :: (a -> b -> b) -> b -> Hashed a -> b # foldr' :: (a -> b -> b) -> b -> Hashed a -> b # foldl :: (b -> a -> b) -> b -> Hashed a -> b # foldl' :: (b -> a -> b) -> b -> Hashed a -> b # foldr1 :: (a -> a -> a) -> Hashed a -> a # foldl1 :: (a -> a -> a) -> Hashed a -> a # toList :: Hashed a -> [a] # null :: Hashed a -> Bool # length :: Hashed a -> Int # elem :: Eq a => a -> Hashed a -> Bool # maximum :: Ord a => Hashed a -> a # minimum :: Ord a => Hashed a -> a # sum :: Num a => Hashed a -> a # product :: Num a => Hashed a -> a #
Foldable TyVarBndr |
Instance details Defined in Language.Haskell.TH.Syntax Methods fold :: Monoid m => TyVarBndr m -> m # foldMap :: Monoid m => (a -> m) -> TyVarBndr a -> m # foldMap' :: Monoid m => (a -> m) -> TyVarBndr a -> m # foldr :: (a -> b -> b) -> b -> TyVarBndr a -> b # foldr' :: (a -> b -> b) -> b -> TyVarBndr a -> b # foldl :: (b -> a -> b) -> b -> TyVarBndr a -> b # foldl' :: (b -> a -> b) -> b -> TyVarBndr a -> b # foldr1 :: (a -> a -> a) -> TyVarBndr a -> a # foldl1 :: (a -> a -> a) -> TyVarBndr a -> a # toList :: TyVarBndr a -> [a] # null :: TyVarBndr a -> Bool # length :: TyVarBndr a -> Int # elem :: Eq a => a -> TyVarBndr a -> Bool # maximum :: Ord a => TyVarBndr a -> a # minimum :: Ord a => TyVarBndr a -> a # sum :: Num a => TyVarBndr a -> a # product :: Num a => TyVarBndr a -> a #
Foldable HashSet |
Instance details Defined in Data.HashSet.Internal Methods fold :: Monoid m => HashSet m -> m # foldMap :: Monoid m => (a -> m) -> HashSet a -> m # foldMap' :: Monoid m => (a -> m) -> HashSet a -> m # foldr :: (a -> b -> b) -> b -> HashSet a -> b # foldr' :: (a -> b -> b) -> b -> HashSet a -> b # foldl :: (b -> a -> b) -> b -> HashSet a -> b # foldl' :: (b -> a -> b) -> b -> HashSet a -> b # foldr1 :: (a -> a -> a) -> HashSet a -> a # foldl1 :: (a -> a -> a) -> HashSet a -> a # toList :: HashSet a -> [a] # null :: HashSet a -> Bool # length :: HashSet a -> Int # elem :: Eq a => a -> HashSet a -> Bool # maximum :: Ord a => HashSet a -> a # minimum :: Ord a => HashSet a -> a # sum :: Num a => HashSet a -> a # product :: Num a => HashSet a -> a #
Foldable Maybe | @since base-2.01
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Maybe m -> m # foldMap :: Monoid m => (a -> m) -> Maybe a -> m # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m # foldr :: (a -> b -> b) -> b -> Maybe a -> b # foldr' :: (a -> b -> b) -> b -> Maybe a -> b # foldl :: (b -> a -> b) -> b -> Maybe a -> b # foldl' :: (b -> a -> b) -> b -> Maybe a -> b # foldr1 :: (a -> a -> a) -> Maybe a -> a # foldl1 :: (a -> a -> a) -> Maybe a -> a # toList :: Maybe a -> [a] # null :: Maybe a -> Bool # length :: Maybe a -> Int # elem :: Eq a => a -> Maybe a -> Bool # maximum :: Ord a => Maybe a -> a # minimum :: Ord a => Maybe a -> a # sum :: Num a => Maybe a -> a # product :: Num a => Maybe a -> a #
Foldable Solo | @since base-4.15
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Solo m -> m # foldMap :: Monoid m => (a -> m) -> Solo a -> m # foldMap' :: Monoid m => (a -> m) -> Solo a -> m # foldr :: (a -> b -> b) -> b -> Solo a -> b # foldr' :: (a -> b -> b) -> b -> Solo a -> b # foldl :: (b -> a -> b) -> b -> Solo a -> b # foldl' :: (b -> a -> b) -> b -> Solo a -> b # foldr1 :: (a -> a -> a) -> Solo a -> a # foldl1 :: (a -> a -> a) -> Solo a -> a # toList :: Solo a -> [a] # null :: Solo a -> Bool # length :: Solo a -> Int # elem :: Eq a => a -> Solo a -> Bool # maximum :: Ord a => Solo a -> a # minimum :: Ord a => Solo a -> a # sum :: Num a => Solo a -> a # product :: Num a => Solo a -> a #
Foldable [] | @since base-2.01
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => [m] -> m # foldMap :: Monoid m => (a -> m) -> [a] -> m # foldMap' :: Monoid m => (a -> m) -> [a] -> m # foldr :: (a -> b -> b) -> b -> [a] -> b # foldr' :: (a -> b -> b) -> b -> [a] -> b # foldl :: (b -> a -> b) -> b -> [a] -> b # foldl' :: (b -> a -> b) -> b -> [a] -> b # foldr1 :: (a -> a -> a) -> [a] -> a # foldl1 :: (a -> a -> a) -> [a] -> a # toList :: [a] -> [a] # null :: [a] -> Bool # length :: [a] -> Int # elem :: Eq a => a -> [a] -> Bool # maximum :: Ord a => [a] -> a # minimum :: Ord a => [a] -> a # sum :: Num a => [a] -> a # product :: Num a => [a] -> a #
Foldable (Arg a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fold :: Monoid m => Arg a m -> m # foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Arg a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 # toList :: Arg a a0 -> [a0] # null :: Arg a a0 -> Bool # length :: Arg a a0 -> Int # elem :: Eq a0 => a0 -> Arg a a0 -> Bool # maximum :: Ord a0 => Arg a a0 -> a0 # minimum :: Ord a0 => Arg a a0 -> a0 # sum :: Num a0 => Arg a a0 -> a0 # product :: Num a0 => Arg a a0 -> a0 #
Foldable (Map k) | Folds in order of increasing key.
Instance details Defined in Data.Map.Internal Methods fold :: Monoid m => Map k m -> m # foldMap :: Monoid m => (a -> m) -> Map k a -> m # foldMap' :: Monoid m => (a -> m) -> Map k a -> m # foldr :: (a -> b -> b) -> b -> Map k a -> b # foldr' :: (a -> b -> b) -> b -> Map k a -> b # foldl :: (b -> a -> b) -> b -> Map k a -> b # foldl' :: (b -> a -> b) -> b -> Map k a -> b # foldr1 :: (a -> a -> a) -> Map k a -> a # foldl1 :: (a -> a -> a) -> Map k a -> a # toList :: Map k a -> [a] # null :: Map k a -> Bool # length :: Map k a -> Int # elem :: Eq a => a -> Map k a -> Bool # maximum :: Ord a => Map k a -> a # minimum :: Ord a => Map k a -> a # sum :: Num a => Map k a -> a # product :: Num a => Map k a -> a #
Foldable (Array i) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Array i m -> m # foldMap :: Monoid m => (a -> m) -> Array i a -> m # foldMap' :: Monoid m => (a -> m) -> Array i a -> m # foldr :: (a -> b -> b) -> b -> Array i a -> b # foldr' :: (a -> b -> b) -> b -> Array i a -> b # foldl :: (b -> a -> b) -> b -> Array i a -> b # foldl' :: (b -> a -> b) -> b -> Array i a -> b # foldr1 :: (a -> a -> a) -> Array i a -> a # foldl1 :: (a -> a -> a) -> Array i a -> a # toList :: Array i a -> [a] # null :: Array i a -> Bool # length :: Array i a -> Int # elem :: Eq a => a -> Array i a -> Bool # maximum :: Ord a => Array i a -> a # minimum :: Ord a => Array i a -> a # sum :: Num a => Array i a -> a # product :: Num a => Array i a -> a #
Foldable (Either a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Either a m -> m # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # toList :: Either a a0 -> [a0] # null :: Either a a0 -> Bool # length :: Either a a0 -> Int # elem :: Eq a0 => a0 -> Either a a0 -> Bool # maximum :: Ord a0 => Either a a0 -> a0 # minimum :: Ord a0 => Either a a0 -> a0 # sum :: Num a0 => Either a a0 -> a0 # product :: Num a0 => Either a a0 -> a0 #
Foldable (Proxy :: Type -> Type) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # toList :: Proxy a -> [a] # null :: Proxy a -> Bool # length :: Proxy a -> Int # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # sum :: Num a => Proxy a -> a # product :: Num a => Proxy a -> a #
Foldable (U1 :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => U1 m -> m # foldMap :: Monoid m => (a -> m) -> U1 a -> m # foldMap' :: Monoid m => (a -> m) -> U1 a -> m # foldr :: (a -> b -> b) -> b -> U1 a -> b # foldr' :: (a -> b -> b) -> b -> U1 a -> b # foldl :: (b -> a -> b) -> b -> U1 a -> b # foldl' :: (b -> a -> b) -> b -> U1 a -> b # foldr1 :: (a -> a -> a) -> U1 a -> a # foldl1 :: (a -> a -> a) -> U1 a -> a # toList :: U1 a -> [a] # null :: U1 a -> Bool # length :: U1 a -> Int # elem :: Eq a => a -> U1 a -> Bool # maximum :: Ord a => U1 a -> a # minimum :: Ord a => U1 a -> a # sum :: Num a => U1 a -> a # product :: Num a => U1 a -> a #
Foldable (UAddr :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => UAddr m -> m # foldMap :: Monoid m => (a -> m) -> UAddr a -> m # foldMap' :: Monoid m => (a -> m) -> UAddr a -> m # foldr :: (a -> b -> b) -> b -> UAddr a -> b # foldr' :: (a -> b -> b) -> b -> UAddr a -> b # foldl :: (b -> a -> b) -> b -> UAddr a -> b # foldl' :: (b -> a -> b) -> b -> UAddr a -> b # foldr1 :: (a -> a -> a) -> UAddr a -> a # foldl1 :: (a -> a -> a) -> UAddr a -> a # toList :: UAddr a -> [a] # null :: UAddr a -> Bool # length :: UAddr a -> Int # elem :: Eq a => a -> UAddr a -> Bool # maximum :: Ord a => UAddr a -> a # minimum :: Ord a => UAddr a -> a # sum :: Num a => UAddr a -> a # product :: Num a => UAddr a -> a #
Foldable (UChar :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => UChar m -> m # foldMap :: Monoid m => (a -> m) -> UChar a -> m # foldMap' :: Monoid m => (a -> m) -> UChar a -> m # foldr :: (a -> b -> b) -> b -> UChar a -> b # foldr' :: (a -> b -> b) -> b -> UChar a -> b # foldl :: (b -> a -> b) -> b -> UChar a -> b # foldl' :: (b -> a -> b) -> b -> UChar a -> b # foldr1 :: (a -> a -> a) -> UChar a -> a # foldl1 :: (a -> a -> a) -> UChar a -> a # toList :: UChar a -> [a] # null :: UChar a -> Bool # length :: UChar a -> Int # elem :: Eq a => a -> UChar a -> Bool # maximum :: Ord a => UChar a -> a # minimum :: Ord a => UChar a -> a # sum :: Num a => UChar a -> a # product :: Num a => UChar a -> a #
Foldable (UDouble :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => UDouble m -> m # foldMap :: Monoid m => (a -> m) -> UDouble a -> m # foldMap' :: Monoid m => (a -> m) -> UDouble a -> m # foldr :: (a -> b -> b) -> b -> UDouble a -> b # foldr' :: (a -> b -> b) -> b -> UDouble a -> b # foldl :: (b -> a -> b) -> b -> UDouble a -> b # foldl' :: (b -> a -> b) -> b -> UDouble a -> b # foldr1 :: (a -> a -> a) -> UDouble a -> a # foldl1 :: (a -> a -> a) -> UDouble a -> a # toList :: UDouble a -> [a] # null :: UDouble a -> Bool # length :: UDouble a -> Int # elem :: Eq a => a -> UDouble a -> Bool # maximum :: Ord a => UDouble a -> a # minimum :: Ord a => UDouble a -> a # sum :: Num a => UDouble a -> a # product :: Num a => UDouble a -> a #
Foldable (UFloat :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => UFloat m -> m # foldMap :: Monoid m => (a -> m) -> UFloat a -> m # foldMap' :: Monoid m => (a -> m) -> UFloat a -> m # foldr :: (a -> b -> b) -> b -> UFloat a -> b # foldr' :: (a -> b -> b) -> b -> UFloat a -> b # foldl :: (b -> a -> b) -> b -> UFloat a -> b # foldl' :: (b -> a -> b) -> b -> UFloat a -> b # foldr1 :: (a -> a -> a) -> UFloat a -> a # foldl1 :: (a -> a -> a) -> UFloat a -> a # toList :: UFloat a -> [a] # null :: UFloat a -> Bool # length :: UFloat a -> Int # elem :: Eq a => a -> UFloat a -> Bool # maximum :: Ord a => UFloat a -> a # minimum :: Ord a => UFloat a -> a # sum :: Num a => UFloat a -> a # product :: Num a => UFloat a -> a #
Foldable (UInt :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => UInt m -> m # foldMap :: Monoid m => (a -> m) -> UInt a -> m # foldMap' :: Monoid m => (a -> m) -> UInt a -> m # foldr :: (a -> b -> b) -> b -> UInt a -> b # foldr' :: (a -> b -> b) -> b -> UInt a -> b # foldl :: (b -> a -> b) -> b -> UInt a -> b # foldl' :: (b -> a -> b) -> b -> UInt a -> b # foldr1 :: (a -> a -> a) -> UInt a -> a # foldl1 :: (a -> a -> a) -> UInt a -> a # toList :: UInt a -> [a] # null :: UInt a -> Bool # length :: UInt a -> Int # elem :: Eq a => a -> UInt a -> Bool # maximum :: Ord a => UInt a -> a # minimum :: Ord a => UInt a -> a # sum :: Num a => UInt a -> a # product :: Num a => UInt a -> a #
Foldable (UWord :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => UWord m -> m # foldMap :: Monoid m => (a -> m) -> UWord a -> m # foldMap' :: Monoid m => (a -> m) -> UWord a -> m # foldr :: (a -> b -> b) -> b -> UWord a -> b # foldr' :: (a -> b -> b) -> b -> UWord a -> b # foldl :: (b -> a -> b) -> b -> UWord a -> b # foldl' :: (b -> a -> b) -> b -> UWord a -> b # foldr1 :: (a -> a -> a) -> UWord a -> a # foldl1 :: (a -> a -> a) -> UWord a -> a # toList :: UWord a -> [a] # null :: UWord a -> Bool # length :: UWord a -> Int # elem :: Eq a => a -> UWord a -> Bool # maximum :: Ord a => UWord a -> a # minimum :: Ord a => UWord a -> a # sum :: Num a => UWord a -> a # product :: Num a => UWord a -> a #
Foldable (V1 :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => V1 m -> m # foldMap :: Monoid m => (a -> m) -> V1 a -> m # foldMap' :: Monoid m => (a -> m) -> V1 a -> m # foldr :: (a -> b -> b) -> b -> V1 a -> b # foldr' :: (a -> b -> b) -> b -> V1 a -> b # foldl :: (b -> a -> b) -> b -> V1 a -> b # foldl' :: (b -> a -> b) -> b -> V1 a -> b # foldr1 :: (a -> a -> a) -> V1 a -> a # foldl1 :: (a -> a -> a) -> V1 a -> a # toList :: V1 a -> [a] # null :: V1 a -> Bool # length :: V1 a -> Int # elem :: Eq a => a -> V1 a -> Bool # maximum :: Ord a => V1 a -> a # minimum :: Ord a => V1 a -> a # sum :: Num a => V1 a -> a # product :: Num a => V1 a -> a #
Foldable f => Foldable (Lift f) |
Instance details Defined in Control.Applicative.Lift Methods fold :: Monoid m => Lift f m -> m # foldMap :: Monoid m => (a -> m) -> Lift f a -> m # foldMap' :: Monoid m => (a -> m) -> Lift f a -> m # foldr :: (a -> b -> b) -> b -> Lift f a -> b # foldr' :: (a -> b -> b) -> b -> Lift f a -> b # foldl :: (b -> a -> b) -> b -> Lift f a -> b # foldl' :: (b -> a -> b) -> b -> Lift f a -> b # foldr1 :: (a -> a -> a) -> Lift f a -> a # foldl1 :: (a -> a -> a) -> Lift f a -> a # toList :: Lift f a -> [a] # null :: Lift f a -> Bool # length :: Lift f a -> Int # elem :: Eq a => a -> Lift f a -> Bool # maximum :: Ord a => Lift f a -> a # minimum :: Ord a => Lift f a -> a # sum :: Num a => Lift f a -> a # product :: Num a => Lift f a -> a #
Foldable f => Foldable (MaybeT f) |
Instance details Defined in Control.Monad.Trans.Maybe Methods fold :: Monoid m => MaybeT f m -> m # foldMap :: Monoid m => (a -> m) -> MaybeT f a -> m # foldMap' :: Monoid m => (a -> m) -> MaybeT f a -> m # foldr :: (a -> b -> b) -> b -> MaybeT f a -> b # foldr' :: (a -> b -> b) -> b -> MaybeT f a -> b # foldl :: (b -> a -> b) -> b -> MaybeT f a -> b # foldl' :: (b -> a -> b) -> b -> MaybeT f a -> b # foldr1 :: (a -> a -> a) -> MaybeT f a -> a # foldl1 :: (a -> a -> a) -> MaybeT f a -> a # toList :: MaybeT f a -> [a] # null :: MaybeT f a -> Bool # length :: MaybeT f a -> Int # elem :: Eq a => a -> MaybeT f a -> Bool # maximum :: Ord a => MaybeT f a -> a # minimum :: Ord a => MaybeT f a -> a # sum :: Num a => MaybeT f a -> a # product :: Num a => MaybeT f a -> a #
Foldable (HashMap k) |
Instance details Defined in Data.HashMap.Internal Methods fold :: Monoid m => HashMap k m -> m # foldMap :: Monoid m => (a -> m) -> HashMap k a -> m # foldMap' :: Monoid m => (a -> m) -> HashMap k a -> m # foldr :: (a -> b -> b) -> b -> HashMap k a -> b # foldr' :: (a -> b -> b) -> b -> HashMap k a -> b # foldl :: (b -> a -> b) -> b -> HashMap k a -> b # foldl' :: (b -> a -> b) -> b -> HashMap k a -> b # foldr1 :: (a -> a -> a) -> HashMap k a -> a # foldl1 :: (a -> a -> a) -> HashMap k a -> a # toList :: HashMap k a -> [a] # null :: HashMap k a -> Bool # length :: HashMap k a -> Int # elem :: Eq a => a -> HashMap k a -> Bool # maximum :: Ord a => HashMap k a -> a # minimum :: Ord a => HashMap k a -> a # sum :: Num a => HashMap k a -> a # product :: Num a => HashMap k a -> a #
Foldable ((,) a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => (a, m) -> m # foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m # foldMap' :: Monoid m => (a0 -> m) -> (a, a0) -> m # foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # toList :: (a, a0) -> [a0] # null :: (a, a0) -> Bool # length :: (a, a0) -> Int # elem :: Eq a0 => a0 -> (a, a0) -> Bool # maximum :: Ord a0 => (a, a0) -> a0 # minimum :: Ord a0 => (a, a0) -> a0 # sum :: Num a0 => (a, a0) -> a0 # product :: Num a0 => (a, a0) -> a0 #
Foldable (Const m :: Type -> Type) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b # foldl :: (b -> a -> b) -> b -> Const m a -> b # foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a # foldl1 :: (a -> a -> a) -> Const m a -> a # toList :: Const m a -> [a] # null :: Const m a -> Bool # length :: Const m a -> Int # elem :: Eq a => a -> Const m a -> Bool # maximum :: Ord a => Const m a -> a # minimum :: Ord a => Const m a -> a # sum :: Num a => Const m a -> a # product :: Num a => Const m a -> a #
Foldable f => Foldable (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Ap f m -> m # foldMap :: Monoid m => (a -> m) -> Ap f a -> m # foldMap' :: Monoid m => (a -> m) -> Ap f a -> m # foldr :: (a -> b -> b) -> b -> Ap f a -> b # foldr' :: (a -> b -> b) -> b -> Ap f a -> b # foldl :: (b -> a -> b) -> b -> Ap f a -> b # foldl' :: (b -> a -> b) -> b -> Ap f a -> b # foldr1 :: (a -> a -> a) -> Ap f a -> a # foldl1 :: (a -> a -> a) -> Ap f a -> a # toList :: Ap f a -> [a] # null :: Ap f a -> Bool # length :: Ap f a -> Int # elem :: Eq a => a -> Ap f a -> Bool # maximum :: Ord a => Ap f a -> a # minimum :: Ord a => Ap f a -> a # sum :: Num a => Ap f a -> a # product :: Num a => Ap f a -> a #
Foldable f => Foldable (Alt f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Alt f m -> m # foldMap :: Monoid m => (a -> m) -> Alt f a -> m # foldMap' :: Monoid m => (a -> m) -> Alt f a -> m # foldr :: (a -> b -> b) -> b -> Alt f a -> b # foldr' :: (a -> b -> b) -> b -> Alt f a -> b # foldl :: (b -> a -> b) -> b -> Alt f a -> b # foldl' :: (b -> a -> b) -> b -> Alt f a -> b # foldr1 :: (a -> a -> a) -> Alt f a -> a # foldl1 :: (a -> a -> a) -> Alt f a -> a # toList :: Alt f a -> [a] # null :: Alt f a -> Bool # length :: Alt f a -> Int # elem :: Eq a => a -> Alt f a -> Bool # maximum :: Ord a => Alt f a -> a # minimum :: Ord a => Alt f a -> a # sum :: Num a => Alt f a -> a # product :: Num a => Alt f a -> a #
Foldable f => Foldable (Rec1 f) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Rec1 f m -> m # foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m # foldMap' :: Monoid m => (a -> m) -> Rec1 f a -> m # foldr :: (a -> b -> b) -> b -> Rec1 f a -> b # foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b # foldl :: (b -> a -> b) -> b -> Rec1 f a -> b # foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b # foldr1 :: (a -> a -> a) -> Rec1 f a -> a # foldl1 :: (a -> a -> a) -> Rec1 f a -> a # toList :: Rec1 f a -> [a] # null :: Rec1 f a -> Bool # length :: Rec1 f a -> Int # elem :: Eq a => a -> Rec1 f a -> Bool # maximum :: Ord a => Rec1 f a -> a # minimum :: Ord a => Rec1 f a -> a # sum :: Num a => Rec1 f a -> a # product :: Num a => Rec1 f a -> a #
Foldable f => Foldable (Backwards f) | Derived instance.
Instance details Defined in Control.Applicative.Backwards Methods fold :: Monoid m => Backwards f m -> m # foldMap :: Monoid m => (a -> m) -> Backwards f a -> m # foldMap' :: Monoid m => (a -> m) -> Backwards f a -> m # foldr :: (a -> b -> b) -> b -> Backwards f a -> b # foldr' :: (a -> b -> b) -> b -> Backwards f a -> b # foldl :: (b -> a -> b) -> b -> Backwards f a -> b # foldl' :: (b -> a -> b) -> b -> Backwards f a -> b # foldr1 :: (a -> a -> a) -> Backwards f a -> a # foldl1 :: (a -> a -> a) -> Backwards f a -> a # toList :: Backwards f a -> [a] # null :: Backwards f a -> Bool # length :: Backwards f a -> Int # elem :: Eq a => a -> Backwards f a -> Bool # maximum :: Ord a => Backwards f a -> a # minimum :: Ord a => Backwards f a -> a # sum :: Num a => Backwards f a -> a # product :: Num a => Backwards f a -> a #
Foldable f => Foldable (ExceptT e f) |
Instance details Defined in Control.Monad.Trans.Except Methods fold :: Monoid m => ExceptT e f m -> m # foldMap :: Monoid m => (a -> m) -> ExceptT e f a -> m # foldMap' :: Monoid m => (a -> m) -> ExceptT e f a -> m # foldr :: (a -> b -> b) -> b -> ExceptT e f a -> b # foldr' :: (a -> b -> b) -> b -> ExceptT e f a -> b # foldl :: (b -> a -> b) -> b -> ExceptT e f a -> b # foldl' :: (b -> a -> b) -> b -> ExceptT e f a -> b # foldr1 :: (a -> a -> a) -> ExceptT e f a -> a # foldl1 :: (a -> a -> a) -> ExceptT e f a -> a # toList :: ExceptT e f a -> [a] # null :: ExceptT e f a -> Bool # length :: ExceptT e f a -> Int # elem :: Eq a => a -> ExceptT e f a -> Bool # maximum :: Ord a => ExceptT e f a -> a # minimum :: Ord a => ExceptT e f a -> a # sum :: Num a => ExceptT e f a -> a # product :: Num a => ExceptT e f a -> a #
Foldable f => Foldable (IdentityT f) |
Instance details Defined in Control.Monad.Trans.Identity Methods fold :: Monoid m => IdentityT f m -> m # foldMap :: Monoid m => (a -> m) -> IdentityT f a -> m # foldMap' :: Monoid m => (a -> m) -> IdentityT f a -> m # foldr :: (a -> b -> b) -> b -> IdentityT f a -> b # foldr' :: (a -> b -> b) -> b -> IdentityT f a -> b # foldl :: (b -> a -> b) -> b -> IdentityT f a -> b # foldl' :: (b -> a -> b) -> b -> IdentityT f a -> b # foldr1 :: (a -> a -> a) -> IdentityT f a -> a # foldl1 :: (a -> a -> a) -> IdentityT f a -> a # toList :: IdentityT f a -> [a] # null :: IdentityT f a -> Bool # length :: IdentityT f a -> Int # elem :: Eq a => a -> IdentityT f a -> Bool # maximum :: Ord a => IdentityT f a -> a # minimum :: Ord a => IdentityT f a -> a # sum :: Num a => IdentityT f a -> a # product :: Num a => IdentityT f a -> a #
Foldable f => Foldable (WriterT w f) |
Instance details Defined in Control.Monad.Trans.Writer.Lazy Methods fold :: Monoid m => WriterT w f m -> m # foldMap :: Monoid m => (a -> m) -> WriterT w f a -> m # foldMap' :: Monoid m => (a -> m) -> WriterT w f a -> m # foldr :: (a -> b -> b) -> b -> WriterT w f a -> b # foldr' :: (a -> b -> b) -> b -> WriterT w f a -> b # foldl :: (b -> a -> b) -> b -> WriterT w f a -> b # foldl' :: (b -> a -> b) -> b -> WriterT w f a -> b # foldr1 :: (a -> a -> a) -> WriterT w f a -> a # foldl1 :: (a -> a -> a) -> WriterT w f a -> a # toList :: WriterT w f a -> [a] # null :: WriterT w f a -> Bool # length :: WriterT w f a -> Int # elem :: Eq a => a -> WriterT w f a -> Bool # maximum :: Ord a => WriterT w f a -> a # minimum :: Ord a => WriterT w f a -> a # sum :: Num a => WriterT w f a -> a # product :: Num a => WriterT w f a -> a #
Foldable f => Foldable (WriterT w f) |
Instance details Defined in Control.Monad.Trans.Writer.Strict Methods fold :: Monoid m => WriterT w f m -> m # foldMap :: Monoid m => (a -> m) -> WriterT w f a -> m # foldMap' :: Monoid m => (a -> m) -> WriterT w f a -> m # foldr :: (a -> b -> b) -> b -> WriterT w f a -> b # foldr' :: (a -> b -> b) -> b -> WriterT w f a -> b # foldl :: (b -> a -> b) -> b -> WriterT w f a -> b # foldl' :: (b -> a -> b) -> b -> WriterT w f a -> b # foldr1 :: (a -> a -> a) -> WriterT w f a -> a # foldl1 :: (a -> a -> a) -> WriterT w f a -> a # toList :: WriterT w f a -> [a] # null :: WriterT w f a -> Bool # length :: WriterT w f a -> Int # elem :: Eq a => a -> WriterT w f a -> Bool # maximum :: Ord a => WriterT w f a -> a # minimum :: Ord a => WriterT w f a -> a # sum :: Num a => WriterT w f a -> a # product :: Num a => WriterT w f a -> a #
Foldable (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods fold :: Monoid m => Constant a m -> m # foldMap :: Monoid m => (a0 -> m) -> Constant a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Constant a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Constant a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Constant a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Constant a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Constant a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 # toList :: Constant a a0 -> [a0] # null :: Constant a a0 -> Bool # length :: Constant a a0 -> Int # elem :: Eq a0 => a0 -> Constant a a0 -> Bool # maximum :: Ord a0 => Constant a a0 -> a0 # minimum :: Ord a0 => Constant a a0 -> a0 # sum :: Num a0 => Constant a a0 -> a0 # product :: Num a0 => Constant a a0 -> a0 #
Foldable f => Foldable (Reverse f) | Fold from right to left.
Instance details Defined in Data.Functor.Reverse Methods fold :: Monoid m => Reverse f m -> m # foldMap :: Monoid m => (a -> m) -> Reverse f a -> m # foldMap' :: Monoid m => (a -> m) -> Reverse f a -> m # foldr :: (a -> b -> b) -> b -> Reverse f a -> b # foldr' :: (a -> b -> b) -> b -> Reverse f a -> b # foldl :: (b -> a -> b) -> b -> Reverse f a -> b # foldl' :: (b -> a -> b) -> b -> Reverse f a -> b # foldr1 :: (a -> a -> a) -> Reverse f a -> a # foldl1 :: (a -> a -> a) -> Reverse f a -> a # toList :: Reverse f a -> [a] # null :: Reverse f a -> Bool # length :: Reverse f a -> Int # elem :: Eq a => a -> Reverse f a -> Bool # maximum :: Ord a => Reverse f a -> a # minimum :: Ord a => Reverse f a -> a # sum :: Num a => Reverse f a -> a # product :: Num a => Reverse f a -> a #
(Foldable f, Foldable g) => Foldable (Product f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods fold :: Monoid m => Product f g m -> m # foldMap :: Monoid m => (a -> m) -> Product f g a -> m # foldMap' :: Monoid m => (a -> m) -> Product f g a -> m # foldr :: (a -> b -> b) -> b -> Product f g a -> b # foldr' :: (a -> b -> b) -> b -> Product f g a -> b # foldl :: (b -> a -> b) -> b -> Product f g a -> b # foldl' :: (b -> a -> b) -> b -> Product f g a -> b # foldr1 :: (a -> a -> a) -> Product f g a -> a # foldl1 :: (a -> a -> a) -> Product f g a -> a # toList :: Product f g a -> [a] # null :: Product f g a -> Bool # length :: Product f g a -> Int # elem :: Eq a => a -> Product f g a -> Bool # maximum :: Ord a => Product f g a -> a # minimum :: Ord a => Product f g a -> a # sum :: Num a => Product f g a -> a # product :: Num a => Product f g a -> a #
(Foldable f, Foldable g) => Foldable (Sum f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Sum Methods fold :: Monoid m => Sum f g m -> m # foldMap :: Monoid m => (a -> m) -> Sum f g a -> m # foldMap' :: Monoid m => (a -> m) -> Sum f g a -> m # foldr :: (a -> b -> b) -> b -> Sum f g a -> b # foldr' :: (a -> b -> b) -> b -> Sum f g a -> b # foldl :: (b -> a -> b) -> b -> Sum f g a -> b # foldl' :: (b -> a -> b) -> b -> Sum f g a -> b # foldr1 :: (a -> a -> a) -> Sum f g a -> a # foldl1 :: (a -> a -> a) -> Sum f g a -> a # toList :: Sum f g a -> [a] # null :: Sum f g a -> Bool # length :: Sum f g a -> Int # elem :: Eq a => a -> Sum f g a -> Bool # maximum :: Ord a => Sum f g a -> a # minimum :: Ord a => Sum f g a -> a # sum :: Num a => Sum f g a -> a # product :: Num a => Sum f g a -> a #
(Foldable f, Foldable g) => Foldable (f :*: g) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => (f :*: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a # toList :: (f :*: g) a -> [a] # null :: (f :*: g) a -> Bool # length :: (f :*: g) a -> Int # elem :: Eq a => a -> (f :*: g) a -> Bool # maximum :: Ord a => (f :*: g) a -> a # minimum :: Ord a => (f :*: g) a -> a # sum :: Num a => (f :*: g) a -> a # product :: Num a => (f :*: g) a -> a #
(Foldable f, Foldable g) => Foldable (f :+: g) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => (f :+: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a # toList :: (f :+: g) a -> [a] # null :: (f :+: g) a -> Bool # length :: (f :+: g) a -> Int # elem :: Eq a => a -> (f :+: g) a -> Bool # maximum :: Ord a => (f :+: g) a -> a # minimum :: Ord a => (f :+: g) a -> a # sum :: Num a => (f :+: g) a -> a # product :: Num a => (f :+: g) a -> a #
Foldable (K1 i c :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => K1 i c m -> m # foldMap :: Monoid m => (a -> m) -> K1 i c a -> m # foldMap' :: Monoid m => (a -> m) -> K1 i c a -> m # foldr :: (a -> b -> b) -> b -> K1 i c a -> b # foldr' :: (a -> b -> b) -> b -> K1 i c a -> b # foldl :: (b -> a -> b) -> b -> K1 i c a -> b # foldl' :: (b -> a -> b) -> b -> K1 i c a -> b # foldr1 :: (a -> a -> a) -> K1 i c a -> a # foldl1 :: (a -> a -> a) -> K1 i c a -> a # toList :: K1 i c a -> [a] # null :: K1 i c a -> Bool # length :: K1 i c a -> Int # elem :: Eq a => a -> K1 i c a -> Bool # maximum :: Ord a => K1 i c a -> a # minimum :: Ord a => K1 i c a -> a # sum :: Num a => K1 i c a -> a # product :: Num a => K1 i c a -> a #
(Foldable f, Foldable g) => Foldable (Compose f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Compose Methods fold :: Monoid m => Compose f g m -> m # foldMap :: Monoid m => (a -> m) -> Compose f g a -> m # foldMap' :: Monoid m => (a -> m) -> Compose f g a -> m # foldr :: (a -> b -> b) -> b -> Compose f g a -> b # foldr' :: (a -> b -> b) -> b -> Compose f g a -> b # foldl :: (b -> a -> b) -> b -> Compose f g a -> b # foldl' :: (b -> a -> b) -> b -> Compose f g a -> b # foldr1 :: (a -> a -> a) -> Compose f g a -> a # foldl1 :: (a -> a -> a) -> Compose f g a -> a # toList :: Compose f g a -> [a] # null :: Compose f g a -> Bool # length :: Compose f g a -> Int # elem :: Eq a => a -> Compose f g a -> Bool # maximum :: Ord a => Compose f g a -> a # minimum :: Ord a => Compose f g a -> a # sum :: Num a => Compose f g a -> a # product :: Num a => Compose f g a -> a #
(Foldable f, Foldable g) => Foldable (f :.: g) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => (f :.: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a # toList :: (f :.: g) a -> [a] # null :: (f :.: g) a -> Bool # length :: (f :.: g) a -> Int # elem :: Eq a => a -> (f :.: g) a -> Bool # maximum :: Ord a => (f :.: g) a -> a # minimum :: Ord a => (f :.: g) a -> a # sum :: Num a => (f :.: g) a -> a # product :: Num a => (f :.: g) a -> a #
Foldable f => Foldable (M1 i c f) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => M1 i c f m -> m # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m # foldMap' :: Monoid m => (a -> m) -> M1 i c f a -> m # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b # foldr1 :: (a -> a -> a) -> M1 i c f a -> a # foldl1 :: (a -> a -> a) -> M1 i c f a -> a # toList :: M1 i c f a -> [a] # null :: M1 i c f a -> Bool # length :: M1 i c f a -> Int # elem :: Eq a => a -> M1 i c f a -> Bool # maximum :: Ord a => M1 i c f a -> a # minimum :: Ord a => M1 i c f a -> a # sum :: Num a => M1 i c f a -> a # product :: Num a => M1 i c f a -> a #

concat :: Foldable t => t [a] -> [a] #

The concatenation of all the elements of a container of lists.

#### Examples

Expand

Basic usage:

    >>> concat (Just [1, 2, 3])
    [1,2,3]

    >>> concat (Left 42)
    []

    >>> concat [[1, 2, 3], [4, 5], [6], []]
    [1,2,3,4,5,6]

and :: Foldable t => t Bool -> Bool #

`and` returns the conjunction of a container of Bools. For the result to be `True`, the container must be finite; `False`, however, results from a `False` value finitely far from the left end.

#### Examples

Expand

Basic usage:

    >>> and []
    True

    >>> and [True]
    True

    >>> and [False]
    False

    >>> and [True, True, False]
    False

    >>> and (False : repeat True) -- Infinite list [False,True,True,True,...
    False

    >>> and (repeat True)
    * Hangs forever *

or :: Foldable t => t Bool -> Bool #

`or` returns the disjunction of a container of Bools. For the result to be `False`, the container must be finite; `True`, however, results from a `True` value finitely far from the left end.

#### Examples

Expand

Basic usage:

    >>> or []
    False

    >>> or [True]
    True

    >>> or [False]
    False

    >>> or [True, True, False]
    True

    >>> or (True : repeat False) -- Infinite list [True,False,False,False,...
    True

    >>> or (repeat False)
    * Hangs forever *

any :: Foldable t => (a -> Bool) -> t a -> Bool #

Determines whether any element of the structure satisfies the predicate.

#### Examples

Expand

Basic usage:

    >>> any (> 3) []
    False

    >>> any (> 3) [1,2]
    False

    >>> any (> 3) [1,2,3,4,5]
    True

    >>> any (> 3) [1..]
    True

    >>> any (> 3) [0, -1..]
    * Hangs forever *

all :: Foldable t => (a -> Bool) -> t a -> Bool #

Determines whether all elements of the structure satisfy the predicate.

#### Examples

Expand

Basic usage:

    >>> all (> 3) []
    True

    >>> all (> 3) [1,2]
    False

    >>> all (> 3) [1,2,3,4,5]
    False

    >>> all (> 3) [1..]
    False

    >>> all (> 3) [4..]
    * Hangs forever *

concatMap :: Foldable t => (a -> [b]) -> t a -> [b] #

Map a function over all the elements of a container and concatenate the resulting lists.

#### Examples

Expand

Basic usage:

    >>> concatMap (take 3) [[1..], [10..], [100..], [1000..]]
    [1,2,3,10,11,12,100,101,102,1000,1001,1002]

    >>> concatMap (take 3) (Just [1..])
    [1,2,3]

foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b #

Left-to-right monadic fold over the elements of a structure.

Given a structure `t` with elements `(a, b, ..., w, x, y)`, the result of a fold with an operator function `f` is equivalent to:

    foldlM f z t = do
        aa <- f z a
        bb <- f aa b
        ...
        xx <- f ww x
        yy <- f xx y
        return yy -- Just @return z@ when the structure is empty

For a Monad `m`, given two functions `f1 :: a -> m b` and `f2 :: b -> m c`, their Kleisli composition `(f1 >=> f2) :: a -> m c` is defined by:

    (f1 >=> f2) a = f1 a >>= f2

Another way of thinking about `foldlM` is that it amounts to an application to `z` of a Kleisli composition:

    foldlM f z t =
        flip f a >=> flip f b >=> ... >=> flip f x >=> flip f y $ z

The monadic effects of `foldlM` are sequenced from left to right.

If at some step the bind operator `(`>>=`)` short-circuits (as with, e.g., `mzero` in a `MonadPlus`), the evaluated effects will be from an initial segment of the element sequence. If you want to evaluate the monadic effects in right-to-left order, or perhaps be able to short-circuit after processing a tail of the sequence of elements, you'll need to use `foldrM` instead.

If the monadic effects don't short-circuit, the outermost application of `f` is to the rightmost element `y`, so that, ignoring effects, the result looks like a left fold:

    ((((z `f` a) `f` b) ... `f` w) `f` x) `f` y

#### Examples

Expand

Basic usage:

    >>> let f a e = do { print e ; return $ e : a }
    >>> foldlM f [] [0..3]
    0
    1
    2
    3
    [3,2,1,0]

traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () #

Map each element of a structure to an `Applicative` action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see `traverse`.

`traverse_` is just like `mapM_`, but generalised to `Applicative` actions.

#### Examples

Expand

Basic usage:

    >>> traverse_ print ["Hello", "world", "!"]
    "Hello"
    "world"
    "!"

for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f () #

`for_` is `traverse_` with its arguments flipped. For a version that doesn't ignore the results see `for`. This is `forM_` generalised to `Applicative` actions.

`for_` is just like `forM_`, but generalised to `Applicative` actions.

#### Examples

Expand

Basic usage:

    >>> for_ [1..4] print
    1
    2
    3
    4

mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () #

Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see `mapM`.

`mapM_` is just like `traverse_`, but specialised to monadic actions.

forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () #

`forM_` is `mapM_` with its arguments flipped. For a version that doesn't ignore the results see `forM`.

`forM_` is just like `for_`, but specialised to monadic actions.

sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f () #

Evaluate each action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results see `sequenceA`.

`sequenceA_` is just like `sequence_`, but generalised to `Applicative` actions.

#### Examples

Expand

Basic usage:

    >>> sequenceA_ [print "Hello", print "world", print "!"]
    "Hello"
    "world"
    "!"

sequence_ :: (Foldable t, Monad m) => t (m a) -> m () #

Evaluate each monadic action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results see `sequence`.

`sequence_` is just like `sequenceA_`, but specialised to monadic actions.

asum :: (Foldable t, Alternative f) => t (f a) -> f a #

The sum of a collection of actions using `(<|>)`, generalizing `concat`.

`asum` is just like `msum`, but generalised to `Alternative`.

#### Examples

Expand

Basic usage:

    >>> asum [Just "Hello", Nothing, Just "World"]
    Just "Hello"

find :: Foldable t => (a -> Bool) -> t a -> Maybe a #

The `find` function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or `Nothing` if there is no such element.

#### Examples

Expand

Basic usage:

    >>> find (> 42) [0, 5..]
    Just 45

    >>> find (> 12) [1..7]
    Nothing

class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where #

Functors representing data structures that can be transformed to structures of the same shape by performing an `Applicative` (or, therefore, `Monad`) action on each element from left to right.

A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.

For the class laws see the Laws section of Data.Traversable.

Minimal complete definition

traverse | sequenceA

Methods

traverse :: Applicative f => (a -> f b) -> t a -> f (t b) #

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see `traverse_`.

#### Examples

Expand

Basic usage:

In the first two examples we show each evaluated action mapping to the output structure.

    >>> traverse Just [1,2,3,4]
    Just [1,2,3,4]

    >>> traverse id [Right 1, Right 2, Right 3, Right 4]
    Right [1,2,3,4]

In the next examples, we show that `Nothing` and `Left` values short circuit the created structure.

    >>> traverse (const Nothing) [1,2,3,4]
    Nothing

    >>> traverse (\x -> if odd x then Just x else Nothing)  [1,2,3,4]
    Nothing

    >>> traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]
    Left 0

sequenceA :: Applicative f => t (f a) -> f (t a) #

Evaluate each action in the structure from left to right, and collect the results. For a version that ignores the results see `sequenceA_`.

#### Examples

Expand

Basic usage:

For the first two examples we show sequenceA fully evaluating a a structure and collecting the results.

    >>> sequenceA [Just 1, Just 2, Just 3]
    Just [1,2,3]

    >>> sequenceA [Right 1, Right 2, Right 3]
    Right [1,2,3]

The next two example show `Nothing` and `Just` will short circuit the resulting structure if present in the input. For more context, check the `Traversable` instances for `Either` and `Maybe`.

    >>> sequenceA [Just 1, Just 2, Just 3, Nothing]
    Nothing

    >>> sequenceA [Right 1, Right 2, Right 3, Left 4]
    Left 4

mapM :: Monad m => (a -> m b) -> t a -> m (t b) #

Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see `mapM_`.

#### Examples

Expand

`mapM` is literally a `traverse` with a type signature restricted to `Monad`. Its implementation may be more efficient due to additional power of `Monad`.

sequence :: Monad m => t (m a) -> m (t a) #

Evaluate each monadic action in the structure from left to right, and collect the results. For a version that ignores the results see `sequence_`.

#### Examples

Expand

Basic usage:

The first two examples are instances where the input and and output of `sequence` are isomorphic.

    >>> sequence $ Right [1,2,3,4]
    [Right 1,Right 2,Right 3,Right 4]

    >>> sequence $ [Right 1,Right 2,Right 3,Right 4]
    Right [1,2,3,4]

The following examples demonstrate short circuit behavior for `sequence`.

    >>> sequence $ Left [1,2,3,4]
    Left [1,2,3,4]

    >>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]
    Left 0

#### Instances

Instances details

Traversable Complex | Since: base-4.9.0.0
Instance details Defined in Data.Complex Methods traverse :: Applicative f => (a -> f b) -> Complex a -> f (Complex b) # sequenceA :: Applicative f => Complex (f a) -> f (Complex a) # mapM :: Monad m => (a -> m b) -> Complex a -> m (Complex b) # sequence :: Monad m => Complex (m a) -> m (Complex a) #
Traversable First | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods traverse :: Applicative f => (a -> f b) -> First a -> f (First b) # sequenceA :: Applicative f => First (f a) -> f (First a) # mapM :: Monad m => (a -> m b) -> First a -> m (First b) # sequence :: Monad m => First (m a) -> m (First a) #
Traversable Last | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods traverse :: Applicative f => (a -> f b) -> Last a -> f (Last b) # sequenceA :: Applicative f => Last (f a) -> f (Last a) # mapM :: Monad m => (a -> m b) -> Last a -> m (Last b) # sequence :: Monad m => Last (m a) -> m (Last a) #
Traversable Max | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods traverse :: Applicative f => (a -> f b) -> Max a -> f (Max b) # sequenceA :: Applicative f => Max (f a) -> f (Max a) # mapM :: Monad m => (a -> m b) -> Max a -> m (Max b) # sequence :: Monad m => Max (m a) -> m (Max a) #
Traversable Min | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods traverse :: Applicative f => (a -> f b) -> Min a -> f (Min b) # sequenceA :: Applicative f => Min (f a) -> f (Min a) # mapM :: Monad m => (a -> m b) -> Min a -> m (Min b) # sequence :: Monad m => Min (m a) -> m (Min a) #
Traversable SCC | Since: containers-0.5.9
Instance details Defined in Data.Graph Methods traverse :: Applicative f => (a -> f b) -> SCC a -> f (SCC b) # sequenceA :: Applicative f => SCC (f a) -> f (SCC a) # mapM :: Monad m => (a -> m b) -> SCC a -> m (SCC b) # sequence :: Monad m => SCC (m a) -> m (SCC a) #
Traversable IntMap | Traverses in order of increasing key.
Instance details Defined in Data.IntMap.Internal Methods traverse :: Applicative f => (a -> f b) -> IntMap a -> f (IntMap b) # sequenceA :: Applicative f => IntMap (f a) -> f (IntMap a) # mapM :: Monad m => (a -> m b) -> IntMap a -> m (IntMap b) # sequence :: Monad m => IntMap (m a) -> m (IntMap a) #
Traversable Digit |
Instance details Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> Digit a -> f (Digit b) # sequenceA :: Applicative f => Digit (f a) -> f (Digit a) # mapM :: Monad m => (a -> m b) -> Digit a -> m (Digit b) # sequence :: Monad m => Digit (m a) -> m (Digit a) #
Traversable Elem |
Instance details Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> Elem a -> f (Elem b) # sequenceA :: Applicative f => Elem (f a) -> f (Elem a) # mapM :: Monad m => (a -> m b) -> Elem a -> m (Elem b) # sequence :: Monad m => Elem (m a) -> m (Elem a) #
Traversable FingerTree |
Instance details Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> FingerTree a -> f (FingerTree b) # sequenceA :: Applicative f => FingerTree (f a) -> f (FingerTree a) # mapM :: Monad m => (a -> m b) -> FingerTree a -> m (FingerTree b) # sequence :: Monad m => FingerTree (m a) -> m (FingerTree a) #
Traversable Node |
Instance details Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> Node a -> f (Node b) # sequenceA :: Applicative f => Node (f a) -> f (Node a) # mapM :: Monad m => (a -> m b) -> Node a -> m (Node b) # sequence :: Monad m => Node (m a) -> m (Node a) #
Traversable Seq |
Instance details Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> Seq a -> f (Seq b) # sequenceA :: Applicative f => Seq (f a) -> f (Seq a) # mapM :: Monad m => (a -> m b) -> Seq a -> m (Seq b) # sequence :: Monad m => Seq (m a) -> m (Seq a) #
Traversable ViewL |
Instance details Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> ViewL a -> f (ViewL b) # sequenceA :: Applicative f => ViewL (f a) -> f (ViewL a) # mapM :: Monad m => (a -> m b) -> ViewL a -> m (ViewL b) # sequence :: Monad m => ViewL (m a) -> m (ViewL a) #
Traversable ViewR |
Instance details Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> ViewR a -> f (ViewR b) # sequenceA :: Applicative f => ViewR (f a) -> f (ViewR a) # mapM :: Monad m => (a -> m b) -> ViewR a -> m (ViewR b) # sequence :: Monad m => ViewR (m a) -> m (ViewR a) #
Traversable Tree |
Instance details Defined in Data.Tree Methods traverse :: Applicative f => (a -> f b) -> Tree a -> f (Tree b) # sequenceA :: Applicative f => Tree (f a) -> f (Tree a) # mapM :: Monad m => (a -> m b) -> Tree a -> m (Tree b) # sequence :: Monad m => Tree (m a) -> m (Tree a) #
Traversable NonEmpty | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> NonEmpty a -> f (NonEmpty b) # sequenceA :: Applicative f => NonEmpty (f a) -> f (NonEmpty a) # mapM :: Monad m => (a -> m b) -> NonEmpty a -> m (NonEmpty b) # sequence :: Monad m => NonEmpty (m a) -> m (NonEmpty a) #
Traversable Identity | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Identity a -> f (Identity b) # sequenceA :: Applicative f => Identity (f a) -> f (Identity a) # mapM :: Monad m => (a -> m b) -> Identity a -> m (Identity b) # sequence :: Monad m => Identity (m a) -> m (Identity a) #
Traversable First | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> First a -> f (First b) # sequenceA :: Applicative f => First (f a) -> f (First a) # mapM :: Monad m => (a -> m b) -> First a -> m (First b) # sequence :: Monad m => First (m a) -> m (First a) #
Traversable Last | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Last a -> f (Last b) # sequenceA :: Applicative f => Last (f a) -> f (Last a) # mapM :: Monad m => (a -> m b) -> Last a -> m (Last b) # sequence :: Monad m => Last (m a) -> m (Last a) #
Traversable Down | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Down a -> f (Down b) # sequenceA :: Applicative f => Down (f a) -> f (Down a) # mapM :: Monad m => (a -> m b) -> Down a -> m (Down b) # sequence :: Monad m => Down (m a) -> m (Down a) #
Traversable Dual | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Dual a -> f (Dual b) # sequenceA :: Applicative f => Dual (f a) -> f (Dual a) # mapM :: Monad m => (a -> m b) -> Dual a -> m (Dual b) # sequence :: Monad m => Dual (m a) -> m (Dual a) #
Traversable Product | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Product a -> f (Product b) # sequenceA :: Applicative f => Product (f a) -> f (Product a) # mapM :: Monad m => (a -> m b) -> Product a -> m (Product b) # sequence :: Monad m => Product (m a) -> m (Product a) #
Traversable Sum | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Sum a -> f (Sum b) # sequenceA :: Applicative f => Sum (f a) -> f (Sum a) # mapM :: Monad m => (a -> m b) -> Sum a -> m (Sum b) # sequence :: Monad m => Sum (m a) -> m (Sum a) #
Traversable ZipList | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Functor.ZipList Methods traverse :: Applicative f => (a -> f b) -> ZipList a -> f (ZipList b) # sequenceA :: Applicative f => ZipList (f a) -> f (ZipList a) # mapM :: Monad m => (a -> m b) -> ZipList a -> m (ZipList b) # sequence :: Monad m => ZipList (m a) -> m (ZipList a) #
Traversable Par1 | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Par1 a -> f (Par1 b) # sequenceA :: Applicative f => Par1 (f a) -> f (Par1 a) # mapM :: Monad m => (a -> m b) -> Par1 a -> m (Par1 b) # sequence :: Monad m => Par1 (m a) -> m (Par1 a) #
Traversable TyVarBndr |
Instance details Defined in Language.Haskell.TH.Syntax Methods traverse :: Applicative f => (a -> f b) -> TyVarBndr a -> f (TyVarBndr b) # sequenceA :: Applicative f => TyVarBndr (f a) -> f (TyVarBndr a) # mapM :: Monad m => (a -> m b) -> TyVarBndr a -> m (TyVarBndr b) # sequence :: Monad m => TyVarBndr (m a) -> m (TyVarBndr a) #
Traversable Maybe | @since base-2.01
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Maybe a -> f (Maybe b) # sequenceA :: Applicative f => Maybe (f a) -> f (Maybe a) # mapM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) # sequence :: Monad m => Maybe (m a) -> m (Maybe a) #
Traversable Solo | @since base-4.15
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Solo a -> f (Solo b) # sequenceA :: Applicative f => Solo (f a) -> f (Solo a) # mapM :: Monad m => (a -> m b) -> Solo a -> m (Solo b) # sequence :: Monad m => Solo (m a) -> m (Solo a) #
Traversable [] | @since base-2.01
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> [a] -> f [b] # sequenceA :: Applicative f => [f a] -> f [a] # mapM :: Monad m => (a -> m b) -> [a] -> m [b] # sequence :: Monad m => [m a] -> m [a] #
Traversable (Arg a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods traverse :: Applicative f => (a0 -> f b) -> Arg a a0 -> f (Arg a b) # sequenceA :: Applicative f => Arg a (f a0) -> f (Arg a a0) # mapM :: Monad m => (a0 -> m b) -> Arg a a0 -> m (Arg a b) # sequence :: Monad m => Arg a (m a0) -> m (Arg a a0) #
Traversable (Map k) | Traverses in order of increasing key.
Instance details Defined in Data.Map.Internal Methods traverse :: Applicative f => (a -> f b) -> Map k a -> f (Map k b) # sequenceA :: Applicative f => Map k (f a) -> f (Map k a) # mapM :: Monad m => (a -> m b) -> Map k a -> m (Map k b) # sequence :: Monad m => Map k (m a) -> m (Map k a) #
Ix i => Traversable (Array i) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Array i a -> f (Array i b) # sequenceA :: Applicative f => Array i (f a) -> f (Array i a) # mapM :: Monad m => (a -> m b) -> Array i a -> m (Array i b) # sequence :: Monad m => Array i (m a) -> m (Array i a) #
Traversable (Either a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a0 -> f b) -> Either a a0 -> f (Either a b) # sequenceA :: Applicative f => Either a (f a0) -> f (Either a a0) # mapM :: Monad m => (a0 -> m b) -> Either a a0 -> m (Either a b) # sequence :: Monad m => Either a (m a0) -> m (Either a a0) #
Traversable (Proxy :: Type -> Type) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Proxy a -> f (Proxy b) # sequenceA :: Applicative f => Proxy (f a) -> f (Proxy a) # mapM :: Monad m => (a -> m b) -> Proxy a -> m (Proxy b) # sequence :: Monad m => Proxy (m a) -> m (Proxy a) #
Traversable (U1 :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> U1 a -> f (U1 b) # sequenceA :: Applicative f => U1 (f a) -> f (U1 a) # mapM :: Monad m => (a -> m b) -> U1 a -> m (U1 b) # sequence :: Monad m => U1 (m a) -> m (U1 a) #
Traversable (UAddr :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> UAddr a -> f (UAddr b) # sequenceA :: Applicative f => UAddr (f a) -> f (UAddr a) # mapM :: Monad m => (a -> m b) -> UAddr a -> m (UAddr b) # sequence :: Monad m => UAddr (m a) -> m (UAddr a) #
Traversable (UChar :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> UChar a -> f (UChar b) # sequenceA :: Applicative f => UChar (f a) -> f (UChar a) # mapM :: Monad m => (a -> m b) -> UChar a -> m (UChar b) # sequence :: Monad m => UChar (m a) -> m (UChar a) #
Traversable (UDouble :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> UDouble a -> f (UDouble b) # sequenceA :: Applicative f => UDouble (f a) -> f (UDouble a) # mapM :: Monad m => (a -> m b) -> UDouble a -> m (UDouble b) # sequence :: Monad m => UDouble (m a) -> m (UDouble a) #
Traversable (UFloat :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> UFloat a -> f (UFloat b) # sequenceA :: Applicative f => UFloat (f a) -> f (UFloat a) # mapM :: Monad m => (a -> m b) -> UFloat a -> m (UFloat b) # sequence :: Monad m => UFloat (m a) -> m (UFloat a) #
Traversable (UInt :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> UInt a -> f (UInt b) # sequenceA :: Applicative f => UInt (f a) -> f (UInt a) # mapM :: Monad m => (a -> m b) -> UInt a -> m (UInt b) # sequence :: Monad m => UInt (m a) -> m (UInt a) #
Traversable (UWord :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> UWord a -> f (UWord b) # sequenceA :: Applicative f => UWord (f a) -> f (UWord a) # mapM :: Monad m => (a -> m b) -> UWord a -> m (UWord b) # sequence :: Monad m => UWord (m a) -> m (UWord a) #
Traversable (V1 :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> V1 a -> f (V1 b) # sequenceA :: Applicative f => V1 (f a) -> f (V1 a) # mapM :: Monad m => (a -> m b) -> V1 a -> m (V1 b) # sequence :: Monad m => V1 (m a) -> m (V1 a) #
Traversable f => Traversable (Lift f) |
Instance details Defined in Control.Applicative.Lift Methods traverse :: Applicative f0 => (a -> f0 b) -> Lift f a -> f0 (Lift f b) # sequenceA :: Applicative f0 => Lift f (f0 a) -> f0 (Lift f a) # mapM :: Monad m => (a -> m b) -> Lift f a -> m (Lift f b) # sequence :: Monad m => Lift f (m a) -> m (Lift f a) #
Traversable f => Traversable (MaybeT f) |
Instance details Defined in Control.Monad.Trans.Maybe Methods traverse :: Applicative f0 => (a -> f0 b) -> MaybeT f a -> f0 (MaybeT f b) # sequenceA :: Applicative f0 => MaybeT f (f0 a) -> f0 (MaybeT f a) # mapM :: Monad m => (a -> m b) -> MaybeT f a -> m (MaybeT f b) # sequence :: Monad m => MaybeT f (m a) -> m (MaybeT f a) #
Traversable (HashMap k) |
Instance details Defined in Data.HashMap.Internal Methods traverse :: Applicative f => (a -> f b) -> HashMap k a -> f (HashMap k b) # sequenceA :: Applicative f => HashMap k (f a) -> f (HashMap k a) # mapM :: Monad m => (a -> m b) -> HashMap k a -> m (HashMap k b) # sequence :: Monad m => HashMap k (m a) -> m (HashMap k a) #
Traversable ((,) a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a0 -> f b) -> (a, a0) -> f (a, b) # sequenceA :: Applicative f => (a, f a0) -> f (a, a0) # mapM :: Monad m => (a0 -> m b) -> (a, a0) -> m (a, b) # sequence :: Monad m => (a, m a0) -> m (a, a0) #
Traversable (Const m :: Type -> Type) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Const m a -> f (Const m b) # sequenceA :: Applicative f => Const m (f a) -> f (Const m a) # mapM :: Monad m0 => (a -> m0 b) -> Const m a -> m0 (Const m b) # sequence :: Monad m0 => Const m (m0 a) -> m0 (Const m a) #
Traversable f => Traversable (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> Ap f a -> f0 (Ap f b) # sequenceA :: Applicative f0 => Ap f (f0 a) -> f0 (Ap f a) # mapM :: Monad m => (a -> m b) -> Ap f a -> m (Ap f b) # sequence :: Monad m => Ap f (m a) -> m (Ap f a) #
Traversable f => Traversable (Alt f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> Alt f a -> f0 (Alt f b) # sequenceA :: Applicative f0 => Alt f (f0 a) -> f0 (Alt f a) # mapM :: Monad m => (a -> m b) -> Alt f a -> m (Alt f b) # sequence :: Monad m => Alt f (m a) -> m (Alt f a) #
Traversable f => Traversable (Rec1 f) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> Rec1 f a -> f0 (Rec1 f b) # sequenceA :: Applicative f0 => Rec1 f (f0 a) -> f0 (Rec1 f a) # mapM :: Monad m => (a -> m b) -> Rec1 f a -> m (Rec1 f b) # sequence :: Monad m => Rec1 f (m a) -> m (Rec1 f a) #
Traversable f => Traversable (Backwards f) | Derived instance.
Instance details Defined in Control.Applicative.Backwards Methods traverse :: Applicative f0 => (a -> f0 b) -> Backwards f a -> f0 (Backwards f b) # sequenceA :: Applicative f0 => Backwards f (f0 a) -> f0 (Backwards f a) # mapM :: Monad m => (a -> m b) -> Backwards f a -> m (Backwards f b) # sequence :: Monad m => Backwards f (m a) -> m (Backwards f a) #
Traversable f => Traversable (ExceptT e f) |
Instance details Defined in Control.Monad.Trans.Except Methods traverse :: Applicative f0 => (a -> f0 b) -> ExceptT e f a -> f0 (ExceptT e f b) # sequenceA :: Applicative f0 => ExceptT e f (f0 a) -> f0 (ExceptT e f a) # mapM :: Monad m => (a -> m b) -> ExceptT e f a -> m (ExceptT e f b) # sequence :: Monad m => ExceptT e f (m a) -> m (ExceptT e f a) #
Traversable f => Traversable (IdentityT f) |
Instance details Defined in Control.Monad.Trans.Identity Methods traverse :: Applicative f0 => (a -> f0 b) -> IdentityT f a -> f0 (IdentityT f b) # sequenceA :: Applicative f0 => IdentityT f (f0 a) -> f0 (IdentityT f a) # mapM :: Monad m => (a -> m b) -> IdentityT f a -> m (IdentityT f b) # sequence :: Monad m => IdentityT f (m a) -> m (IdentityT f a) #
Traversable f => Traversable (WriterT w f) |
Instance details Defined in Control.Monad.Trans.Writer.Lazy Methods traverse :: Applicative f0 => (a -> f0 b) -> WriterT w f a -> f0 (WriterT w f b) # sequenceA :: Applicative f0 => WriterT w f (f0 a) -> f0 (WriterT w f a) # mapM :: Monad m => (a -> m b) -> WriterT w f a -> m (WriterT w f b) # sequence :: Monad m => WriterT w f (m a) -> m (WriterT w f a) #
Traversable f => Traversable (WriterT w f) |
Instance details Defined in Control.Monad.Trans.Writer.Strict Methods traverse :: Applicative f0 => (a -> f0 b) -> WriterT w f a -> f0 (WriterT w f b) # sequenceA :: Applicative f0 => WriterT w f (f0 a) -> f0 (WriterT w f a) # mapM :: Monad m => (a -> m b) -> WriterT w f a -> m (WriterT w f b) # sequence :: Monad m => WriterT w f (m a) -> m (WriterT w f a) #
Traversable (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods traverse :: Applicative f => (a0 -> f b) -> Constant a a0 -> f (Constant a b) # sequenceA :: Applicative f => Constant a (f a0) -> f (Constant a a0) # mapM :: Monad m => (a0 -> m b) -> Constant a a0 -> m (Constant a b) # sequence :: Monad m => Constant a (m a0) -> m (Constant a a0) #
Traversable f => Traversable (Reverse f) | Traverse from right to left.
Instance details Defined in Data.Functor.Reverse Methods traverse :: Applicative f0 => (a -> f0 b) -> Reverse f a -> f0 (Reverse f b) # sequenceA :: Applicative f0 => Reverse f (f0 a) -> f0 (Reverse f a) # mapM :: Monad m => (a -> m b) -> Reverse f a -> m (Reverse f b) # sequence :: Monad m => Reverse f (m a) -> m (Reverse f a) #
(Traversable f, Traversable g) => Traversable (Product f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods traverse :: Applicative f0 => (a -> f0 b) -> Product f g a -> f0 (Product f g b) # sequenceA :: Applicative f0 => Product f g (f0 a) -> f0 (Product f g a) # mapM :: Monad m => (a -> m b) -> Product f g a -> m (Product f g b) # sequence :: Monad m => Product f g (m a) -> m (Product f g a) #
(Traversable f, Traversable g) => Traversable (Sum f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Sum Methods traverse :: Applicative f0 => (a -> f0 b) -> Sum f g a -> f0 (Sum f g b) # sequenceA :: Applicative f0 => Sum f g (f0 a) -> f0 (Sum f g a) # mapM :: Monad m => (a -> m b) -> Sum f g a -> m (Sum f g b) # sequence :: Monad m => Sum f g (m a) -> m (Sum f g a) #
(Traversable f, Traversable g) => Traversable (f :*: g) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> (f :*: g) a -> f0 ((f :*: g) b) # sequenceA :: Applicative f0 => (f :*: g) (f0 a) -> f0 ((f :*: g) a) # mapM :: Monad m => (a -> m b) -> (f :*: g) a -> m ((f :*: g) b) # sequence :: Monad m => (f :*: g) (m a) -> m ((f :*: g) a) #
(Traversable f, Traversable g) => Traversable (f :+: g) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> (f :+: g) a -> f0 ((f :+: g) b) # sequenceA :: Applicative f0 => (f :+: g) (f0 a) -> f0 ((f :+: g) a) # mapM :: Monad m => (a -> m b) -> (f :+: g) a -> m ((f :+: g) b) # sequence :: Monad m => (f :+: g) (m a) -> m ((f :+: g) a) #
Traversable (K1 i c :: Type -> Type) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> K1 i c a -> f (K1 i c b) # sequenceA :: Applicative f => K1 i c (f a) -> f (K1 i c a) # mapM :: Monad m => (a -> m b) -> K1 i c a -> m (K1 i c b) # sequence :: Monad m => K1 i c (m a) -> m (K1 i c a) #
(Traversable f, Traversable g) => Traversable (Compose f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Compose Methods traverse :: Applicative f0 => (a -> f0 b) -> Compose f g a -> f0 (Compose f g b) # sequenceA :: Applicative f0 => Compose f g (f0 a) -> f0 (Compose f g a) # mapM :: Monad m => (a -> m b) -> Compose f g a -> m (Compose f g b) # sequence :: Monad m => Compose f g (m a) -> m (Compose f g a) #
(Traversable f, Traversable g) => Traversable (f :.: g) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> (f :.: g) a -> f0 ((f :.: g) b) # sequenceA :: Applicative f0 => (f :.: g) (f0 a) -> f0 ((f :.: g) a) # mapM :: Monad m => (a -> m b) -> (f :.: g) a -> m ((f :.: g) b) # sequence :: Monad m => (f :.: g) (m a) -> m ((f :.: g) a) #
Traversable f => Traversable (M1 i c f) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> M1 i c f a -> f0 (M1 i c f b) # sequenceA :: Applicative f0 => M1 i c f (f0 a) -> f0 (M1 i c f a) # mapM :: Monad m => (a -> m b) -> M1 i c f a -> m (M1 i c f b) # sequence :: Monad m => M1 i c f (m a) -> m (M1 i c f a) #

forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) #

`forM` is `mapM` with its arguments flipped. For a version that ignores the results see `forM_`.

mapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b) #

The `mapAccumL` function behaves like a combination of `fmap` and `foldl`; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.

#### Examples

Expand

Basic usage:

    >>> mapAccumL (\a b -> (a + b, a)) 0 [1..10]
    (55,[0,1,3,6,10,15,21,28,36,45])

    >>> mapAccumL (\a b -> (a <> show b, a)) "0" [1..5]
    ("012345",["0","01","012","0123","01234"])

mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b) #

The `mapAccumR` function behaves like a combination of `fmap` and `foldr`; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.

#### Examples

Expand

Basic usage:

    >>> mapAccumR (\a b -> (a + b, a)) 0 [1..10]
    (55,[54,52,49,45,40,34,27,19,10,0])

    >>> mapAccumR (\a b -> (a <> show b, a)) "0" [1..5]
    ("054321",["05432","0543","054","05","0"])

# `Bi` reexports

class Bifoldable (p :: Type -> Type -> Type) where #

`Bifoldable` identifies foldable structures with two different varieties of elements (as opposed to `Foldable`, which has one variety of element). Common examples are `Either` and `(,)`:

    instance Bifoldable Either where
      bifoldMap f _ (Left  a) = f a
      bifoldMap _ g (Right b) = g b

    instance Bifoldable (,) where
      bifoldr f g z (a, b) = f a (g b z)

Some examples below also use the following BiList to showcase empty Bifoldable behaviors when relevant (`Either` and `(,)` containing always exactly resp. 1 and 2 elements):

    data BiList a b = BiList [a] [b]

    instance Bifoldable BiList where
      bifoldr f g z (BiList as bs) = foldr f (foldr g z bs) as

A minimal `Bifoldable` definition consists of either `bifoldMap` or `bifoldr`. When defining more than this minimal set, one should ensure that the following identities hold:

    bifold ≡ bifoldMap id id
    bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty
    bifoldr f g z t ≡ appEndo (bifoldMap (Endo . f) (Endo . g) t) z

If the type is also an instance of `Foldable`, then it must satisfy (up to laziness):

    bifoldl const ≡ foldl
    bifoldr (flip const) ≡ foldr
    bifoldMap (const mempty) ≡ foldMap

If the type is also a `Bifunctor` instance, it should satisfy:

    bifoldMap f g ≡ bifold . bimap f g

which implies that

    bifoldMap f g . bimap h i ≡ bifoldMap (f . h) (g . i)

Since: base-4.10.0.0

Minimal complete definition

bifoldr | bifoldMap

Methods

bifold :: Monoid m => p m m -> m #

Combines the elements of a structure using a monoid.

    bifold ≡ bifoldMap id id

#### Examples

Expand

Basic usage:

    >>> bifold (Right [1, 2, 3])
    [1,2,3]

    >>> bifold (Left [5, 6])
    [5,6]

    >>> bifold ([1, 2, 3], [4, 5])
    [1,2,3,4,5]

    >>> bifold (Product 6, Product 7)
    Product {getProduct = 42}

    >>> bifold (Sum 6, Sum 7)
    Sum {getSum = 13}

Since: base-4.10.0.0

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> p a b -> m #

Combines the elements of a structure, given ways of mapping them to a common monoid.

    bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty

#### Examples

Expand

Basic usage:

    >>> bifoldMap (take 3) (fmap digitToInt) ([1..], "89")
    [1,2,3,8,9]

    >>> bifoldMap (take 3) (fmap digitToInt) (Left [1..])
    [1,2,3]

    >>> bifoldMap (take 3) (fmap digitToInt) (Right "89")
    [8,9]

Since: base-4.10.0.0

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c #

Combines the elements of a structure in a right 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:

    bifoldr f g z ≡ foldr (either f g) z . toEitherList

#### Examples

Expand

Basic usage:

    > bifoldr (+) (*) 3 (5, 7)
    26 -- 5 + (7 * 3)

    > bifoldr (+) (*) 3 (7, 5)
    22 -- 7 + (5 * 3)

    > bifoldr (+) (*) 3 (Right 5)
    15 -- 5 * 3

    > bifoldr (+) (*) 3 (Left 5)
    8 -- 5 + 3

Since: base-4.10.0.0

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c #

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

Expand

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

Since: base-4.10.0.0

#### Instances

Instances details

Bifoldable Arg | Since: base-4.10.0.0
Instance details Defined in Data.Semigroup Methods bifold :: Monoid m => Arg m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Arg a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Arg a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Arg a b -> c #
Bifoldable Map | Since: containers-0.6.3.1
Instance details Defined in Data.Map.Internal Methods bifold :: Monoid m => Map m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Map a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Map a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Map a b -> c #
Bifoldable Either | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => Either m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Either a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Either a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Either a b -> c #
Bifoldable HashMap | Since: unordered-containers-0.2.11
Instance details Defined in Data.HashMap.Internal Methods bifold :: Monoid m => HashMap m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> HashMap a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> HashMap a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> HashMap a b -> c #
Bifoldable (,) | Class laws for tuples hold only up to laziness. The Bifoldable methods are lazier than their Foldable counterparts. For example the law ``bifoldr` (`flip` `const`) ≡ `foldr`` does not hold for tuples if laziness is exploited:
    >>> bifoldr (flip const) (:) [] (undefined :: (Int, Word)) `seq` ()
    ()
    >>> foldr (:) [] (undefined :: (Int, Word)) `seq` ()
    *** Exception: Prelude.undefined
Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => (m, m) -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (a, b) -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (a, b) -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (a, b) -> c #
Bifoldable (Const :: Type -> Type -> Type) | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => Const m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Const a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Const a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Const a b -> c #
Bifoldable (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods bifold :: Monoid m => Constant m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Constant a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Constant a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Constant a b -> c #
Bifoldable ((,,) x) | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => (x, m, m) -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, a, b) -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, a, b) -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, a, b) -> c #
Bifoldable (K1 i :: Type -> Type -> Type) | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => K1 i m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> K1 i a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> K1 i a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> K1 i a b -> c #
Bifoldable ((,,,) x y) | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => (x, y, m, m) -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, a, b) -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, a, b) -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, a, b) -> c #
Bifoldable ((,,,,) x y z) | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => (x, y, z, m, m) -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, z, a, b) -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, z, a, b) -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, z, a, b) -> c #
Bifoldable ((,,,,,) x y z w) | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => (x, y, z, w, m, m) -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, z, w, a, b) -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, z, w, a, b) -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, z, w, a, b) -> c #
Bifoldable ((,,,,,,) x y z w v) | Since: base-4.10.0.0
Instance details Defined in Data.Bifoldable Methods bifold :: Monoid m => (x, y, z, w, v, m, m) -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, z, w, v, a, b) -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, z, w, v, a, b) -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, z, w, v, a, b) -> c #

bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c #

As `bifoldr`, but strict in the result of the reduction functions at each step.

Since: base-4.10.0.0

bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c #

Right associative monadic bifold over a structure.

Since: base-4.10.0.0

bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a #

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`).

Since: base-4.10.0.0

bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a #

Left associative monadic bifold over a structure.

#### Examples

Expand

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

Since: base-4.10.0.0

bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f () #

Map each element of a structure using one of two actions, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results, see `bitraverse`.

#### Examples

Expand

Basic usage:

    >>> bitraverse_ print (print . show) ("Hello", True)
    "Hello"
    "True"

    >>> bitraverse_ print (print . show) (Right True)
    "True"

    >>> bitraverse_ print (print . show) (Left "Hello")
    "Hello"

Since: base-4.10.0.0

bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f () #

As `bitraverse_`, but with the structure as the primary argument. For a version that doesn't ignore the results, see `bifor`.

#### Examples

Expand

Basic usage:

    >>> bifor_ ("Hello", True) print (print . show)
    "Hello"
    "True"

    >>> bifor_ (Right True) print (print . show)
    "True"

    >>> bifor_ (Left "Hello") print (print . show)
    "Hello"

Since: base-4.10.0.0

bisequence_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f () #

Evaluate each action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results, see `bisequence`.

#### Examples

Expand

Basic usage:

    >>> bisequence_ (print "Hello", print "World")
    "Hello"
    "World"

    >>> bisequence_ (Left (print "Hello"))
    "Hello"

    >>> bisequence_ (Right (print "World"))
    "World"

Since: base-4.10.0.0

biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a #

The sum of a collection of actions, generalizing `biconcat`.

#### Examples

Expand

Basic usage:

    >>> biasum (Nothing, Nothing)
    Nothing

    >>> biasum (Nothing, Just 42)
    Just 42

    >>> biasum (Just 18, Nothing)
    Just 18

    >>> biasum (Just 18, Just 42)
    Just 18

Since: base-4.10.0.0

biList :: Bifoldable t => t a a -> [a] #

Collects the list of elements of a structure, from left to right.

#### Examples

Expand

Basic usage:

    >>> biList (18, 42)
    [18,42]

    >>> biList (Left 18)
    [18]

Since: base-4.10.0.0

binull :: Bifoldable t => t a b -> Bool #

Test whether the structure is empty.

#### Examples

Expand

Basic usage:

    >>> binull (18, 42)
    False

    >>> binull (Right 42)
    False

    >>> binull (BiList [] [])
    True

Since: base-4.10.0.0

bilength :: Bifoldable t => t a b -> Int #

Returns the size/length of a finite structure as an `Int`.

#### Examples

Expand

Basic usage:

    >>> bilength (True, 42)
    2

    >>> bilength (Right 42)
    1

    >>> bilength (BiList [1,2,3] [4,5])
    5

    >>> bilength (BiList [] [])
    0

On infinite structures, this function hangs:

    > bilength (BiList [1..] [])
    * Hangs forever *

Since: base-4.10.0.0

bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool #

Does the element occur in the structure?

#### Examples

Expand

Basic usage:

    >>> bielem 42 (17, 42)
    True

    >>> bielem 42 (17, 43)
    False

    >>> bielem 42 (Left 42)
    True

    >>> bielem 42 (Right 13)
    False

    >>> bielem 42 (BiList [1..5] [1..100])
    True

    >>> bielem 42 (BiList [1..5] [1..41])
    False

Since: base-4.10.0.0

biand :: Bifoldable t => t Bool Bool -> Bool #

`biand` returns the conjunction of a container of Bools. For the result to be `True`, the container must be finite; `False`, however, results from a `False` value finitely far from the left end.

#### Examples

Expand

Basic usage:

    >>> biand (True, False)
    False

    >>> biand (True, True)
    True

    >>> biand (Left True)
    True

Empty structures yield `True`:

    >>> biand (BiList [] [])
    True

A `False` value finitely far from the left end yields `False` (short circuit):

    >>> biand (BiList [True, True, False, True] (repeat True))
    False

A `False` value infinitely far from the left end hangs:

    > biand (BiList (repeat True) [False])
    * Hangs forever *

An infinitely `True` value hangs:

    > biand (BiList (repeat True) [])
    * Hangs forever *

Since: base-4.10.0.0

bior :: Bifoldable t => t Bool Bool -> Bool #

`bior` returns the disjunction of a container of Bools. For the result to be `False`, the container must be finite; `True`, however, results from a `True` value finitely far from the left end.

#### Examples

Expand

Basic usage:

    >>> bior (True, False)
    True

    >>> bior (False, False)
    False

    >>> bior (Left True)
    True

Empty structures yield `False`:

    >>> bior (BiList [] [])
    False

A `True` value finitely far from the left end yields `True` (short circuit):

    >>> bior (BiList [False, False, True, False] (repeat False))
    True

A `True` value infinitely far from the left end hangs:

    > bior (BiList (repeat False) [True])
    * Hangs forever *

An infinitely `False` value hangs:

    > bior (BiList (repeat False) [])
    * Hangs forever *

Since: base-4.10.0.0

biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool #

Determines whether any element of the structure satisfies its appropriate predicate argument. Empty structures yield `False`.

#### Examples

Expand

Basic usage:

    >>> biany even isDigit (27, 't')
    False

    >>> biany even isDigit (27, '8')
    True

    >>> biany even isDigit (26, 't')
    True

    >>> biany even isDigit (Left 27)
    False

    >>> biany even isDigit (Left 26)
    True

    >>> biany even isDigit (BiList [27, 53] ['t', '8'])
    True

Empty structures yield `False`:

    >>> biany even isDigit (BiList [] [])
    False

Since: base-4.10.0.0

biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool #

Determines whether all elements of the structure satisfy their appropriate predicate argument. Empty structures yield `True`.

#### Examples

Expand

Basic usage:

    >>> biall even isDigit (27, 't')
    False

    >>> biall even isDigit (26, '8')
    True

    >>> biall even isDigit (Left 27)
    False

    >>> biall even isDigit (Left 26)
    True

    >>> biall even isDigit (BiList [26, 52] ['3', '8'])
    True

Empty structures yield `True`:

    >>> biall even isDigit (BiList [] [])
    True

Since: base-4.10.0.0

bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a #

The `bifind` function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or `Nothing` if there is no such element.

#### Examples

Expand

Basic usage:

    >>> bifind even (27, 53)
    Nothing

    >>> bifind even (27, 52)
    Just 52

    >>> bifind even (26, 52)
    Just 26

Empty structures always yield `Nothing`:

    >>> bifind even (BiList [] [])
    Nothing

Since: base-4.10.0.0

class (Bifunctor t, Bifoldable t) => Bitraversable (t :: Type -> Type -> Type) where #

`Bitraversable` identifies bifunctorial data structures whose elements can be traversed in order, performing `Applicative` or `Monad` actions at each element, and collecting a result structure with the same shape.

As opposed to `Traversable` data structures, which have one variety of element on which an action can be performed, `Bitraversable` data structures have two such varieties of elements.

A definition of `bitraverse` must satisfy the following laws:

Naturality
  ``bitraverse` (t . f) (t . g) ≡ t . `bitraverse` f g` for every applicative transformation `t`
Identity
  ``bitraverse` `Identity` `Identity` ≡ `Identity``
Composition
  ``Compose` . `fmap` (`bitraverse` g1 g2) . `bitraverse` f1 f2 ≡ `bitraverse` (`Compose` . `fmap` g1 . f1) (`Compose` . `fmap` g2 . f2)`

where an applicative transformation is a function

    t :: (Applicative f, Applicative g) => f a -> g a

preserving the `Applicative` operations:

    t (pure x) ≡ pure x
    t (f <*> x) ≡ t f <*> t x

and the identity functor `Identity` and composition functors `Compose` are from Data.Functor.Identity and Data.Functor.Compose.

Some simple examples are `Either` and `(,)`:

    instance Bitraversable Either where
      bitraverse f _ (Left x) = Left <$> f x
      bitraverse _ g (Right y) = Right <$> g y

    instance Bitraversable (,) where
      bitraverse f g (x, y) = (,) <$> f x <*> g y

`Bitraversable` relates to its superclasses in the following ways:

    bimap f g ≡ runIdentity . bitraverse (Identity . f) (Identity . g)
    bifoldMap f g ≡ getConst . bitraverse (Const . f) (Const . g)

These are available as `bimapDefault` and `bifoldMapDefault` respectively.

If the type is also an instance of `Traversable`, then it must satisfy (up to laziness):

    traverse ≡ bitraverse pure

Since: base-4.10.0.0

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f (t c d) #

Evaluates the relevant functions at each element in the structure, running the action, and builds a new structure with the same shape, using the results produced from sequencing the actions.

    bitraverse f g ≡ bisequenceA . bimap f g

For a version that ignores the results, see `bitraverse_`.

#### Examples

Expand

Basic usage:

    >>> bitraverse listToMaybe (find odd) (Left [])
    Nothing

    >>> bitraverse listToMaybe (find odd) (Left [1, 2, 3])
    Just (Left 1)

    >>> bitraverse listToMaybe (find odd) (Right [4, 5])
    Just (Right 5)

    >>> bitraverse listToMaybe (find odd) ([1, 2, 3], [4, 5])
    Just (1,5)

    >>> bitraverse listToMaybe (find odd) ([], [4, 5])
    Nothing

Since: base-4.10.0.0

#### Instances

Instances details

Bitraversable Arg | Since: base-4.10.0.0
Instance details Defined in Data.Semigroup Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Arg a b -> f (Arg c d) #
Bitraversable Either | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Either a b -> f (Either c d) #
Bitraversable (,) | Class laws for tuples hold only up to laziness. The Bitraversable methods are lazier than their Traversable counterparts. For example the law ``bitraverse` `pure` ≡ `traverse`` does not hold for tuples if laziness is exploited:
    >>> (bitraverse pure pure undefined :: IO (Int, Word)) `seq` ()
    ()
    >>> (traverse pure undefined :: IO (Int, Word)) `seq` ()
    *** Exception: Prelude.undefined
Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (a, b) -> f (c, d) #
Bitraversable (Const :: Type -> Type -> Type) | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Const a b -> f (Const c d) #
Bitraversable (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Constant a b -> f (Constant c d) #
Bitraversable ((,,) x) | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (x, a, b) -> f (x, c, d) #
Bitraversable (K1 i :: Type -> Type -> Type) | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> K1 i a b -> f (K1 i c d) #
Bitraversable ((,,,) x y) | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (x, y, a, b) -> f (x, y, c, d) #
Bitraversable ((,,,,) x y z) | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (x, y, z, a, b) -> f (x, y, z, c, d) #
Bitraversable ((,,,,,) x y z w) | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (x, y, z, w, a, b) -> f (x, y, z, w, c, d) #
Bitraversable ((,,,,,,) x y z w v) | Since: base-4.10.0.0
Instance details Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (x, y, z, w, v, a, b) -> f (x, y, z, w, v, c, d) #

bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d) #

`bifor` is `bitraverse` with the structure as the first argument. For a version that ignores the results, see `bifor_`.

#### Examples

Expand

Basic usage:

    >>> bifor (Left []) listToMaybe (find even)
    Nothing

    >>> bifor (Left [1, 2, 3]) listToMaybe (find even)
    Just (Left 1)

    >>> bifor (Right [4, 5]) listToMaybe (find even)
    Just (Right 4)

    >>> bifor ([1, 2, 3], [4, 5]) listToMaybe (find even)
    Just (1,4)

    >>> bifor ([], [4, 5]) listToMaybe (find even)
    Nothing

Since: base-4.10.0.0

bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) #

Sequences all the actions in a structure, building a new structure with the same shape using the results of the actions. For a version that ignores the results, see `bisequence_`.

    bisequence ≡ bitraverse id id

#### Examples

Expand

Basic usage:

    >>> bisequence (Just 4, Nothing)
    Nothing

    >>> bisequence (Just 4, Just 5)
    Just (4,5)

    >>> bisequence ([1, 2, 3], [4, 5])
    [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]

Since: base-4.10.0.0

bimapDefault :: Bitraversable t => (a -> b) -> (c -> d) -> t a c -> t b d #

A default definition of `bimap` in terms of the `Bitraversable` operations.

    bimapDefault f g ≡
         runIdentity . bitraverse (Identity . f) (Identity . g)

Since: base-4.10.0.0

bifoldMapDefault :: (Bitraversable t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m #

A default definition of `bifoldMap` in terms of the `Bitraversable` operations.

    bifoldMapDefault f g ≡
        getConst . bitraverse (Const . f) (Const . g)

Since: base-4.10.0.0