Reputation: 24518
I'm new to Haskell, and wondering what would be an idiomatic way to convert a tuple (a,b)
to (c,b)
. In other words, only transform the first value, leaving the second unchanged.
I can, of course, use fst
and snd
, but if I can map
over lists, why not tuples?
Upvotes: 1
Views: 1790
Reputation: 152707
Any of these will do:
base:Data.Bifunctor.first
base:Control.Arrow.first
extra:Data.Tuple.Extra.first
(lens:Control.Lens._1 lens:Control.Lens.%~)
Upvotes: 9