Data.Bitraversable.Compat

base-compat-0.14.1: A compatibility layer for base

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Bitraversable.Compat

Synopsis

- module Data.Bitraversable
- 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

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: 4.21.0.0