bimap is:exact

Map over both arguments at the same time.
bimap f g ≡ first f . second g

Examples

>>> bimap toUpper (+1) ('j', 3)
('J',4)
>>> bimap toUpper (+1) (Left 'j')
Left 'J'
>>> bimap toUpper (+1) (Right 3)
Right 4
Bidirectional mapping between two key types A data structure representing a bidirectional mapping between two key types. Each value in the bimap is associated with exactly one value of the opposite type.
Transform a graph by applying given functions to the vertices of each part. Complexity: O((n + m) * log(n)) time.
bimap f g empty           == empty
bimap f g . vertex        == vertex . Data.Bifunctor.bimap f g
bimap f g (edge x y)      == edge (f x) (g y)
bimap id id               == id
bimap f1 g1 . bimap f2 g2 == bimap (f1 . f2) (g1 . g2)
Map over both sides of a symbolic Either at the same time
>>> let f = uninterpret "f" :: SInteger -> SInteger

>>> let g = uninterpret "g" :: SInteger -> SInteger

>>> prove $ \x -> fromLeft (bimap f g (sLeft x)) .== f x
Q.E.D.

>>> prove $ \x -> fromRight (bimap f g (sRight x)) .== g x
Q.E.D.