Data.Bitraversable.Compat

base-compat-batteries-0.14.1: base-compat with extra batteries

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Bitraversable.Compat

Synopsis

- module Data.Bitraversable.Compat
- firstA :: (Bitraversable t, Applicative f) => (a -> f c) -> t a b -> f (t c b)
- secondA :: (Bitraversable t, Applicative f) => (b -> f c) -> t a b -> f (t a c)

# Documentation

module Data.Bitraversable.Compat

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

Traverses only over the first argument.

    firstA f ≡ bitraverse f pure

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

Traverses only over the second argument.

    secondA f ≡ bitraverse pure f

#### Examples

Expand

Basic usage:

    >>> secondA (find odd) (Left [])
    Just (Left [])

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

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

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

    >>> secondA (find odd) ([1,2,3], [4])
    Nothing

Since: base-compat-4.21.0.0