snd -package:linear-base -package:base-compat package:relude

Extract the second component of a pair.
Returns second element of tuple type (with kind *) or type-level tuple (with kind (k1, k2), marked by prefix quote).
>>> :kind! Maybe (Snd '(Int, Text))
Maybe (Snd '(Int, Text)) :: *
= Maybe Text

>>> :kind! Maybe (Snd (Int, Text))
Maybe (Snd (Int, Text)) :: *
= Maybe Text
Like fmap, but also keep the original value in the fst position. A dual to fmapToFst.
>>> fmapToSnd show [3, 10, 2]
[(3,"3"),(10,"10"),(2,"2")]
Deprecated: Use toSnd from Tuple instead
Apply a function, with the result in the snd slot, and the value in the other. A dual to toFst.
>>> toSnd length [3, 1, 0, 2]
([3,1,0,2],4)

>>> toSnd (+5) 10
(10,15)
Apply a function that returns a value inside of a functor, with the output in the second slot, the input in the first, and the entire tuple inside the functor. A dual to traverseToFst.
>>> traverseToSnd (Just . (+1)) 10
Just (10,11)

>>> traverseToSnd (const Nothing) 10
Nothing