Haskell Language Lists Transforming with `map`


Often we wish to convert, or transform the contents of a collection (a list, or something traversable). In Haskell we use map:

 -- Simple add 1
 map (+ 1) [1,2,3]
 map odd [1,2,3]
 data Gender = Male | Female deriving Show
 data Person = Person String Gender Int deriving Show

 -- Extract just the age from a list of people
 map (\(Person n g a) -> a) [(Person "Alex" Male 31),(Person "Ellie" Female 29)]