base-compat
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Bitraversable.Compat

Synopsis

Documentation

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