- Open src/Main.hs, and import Prelude, hiding two functions map and filter. These are the very functions we will implement:
import Prelude hiding (map, filter)
- Write the declaration of map. A map is a function that takes a function, applies it to each member of the list, and returns the transformed list:
map :: (a -> b) -> [a] -> [b]
Note the brackets around (a -> b). It denotes that it is a function that takes an argument of type a and returns a value of type b. Without the brackets, Haskell will interpret the function declaration differently.
The map function takes two arguments and a return value, as described:
- The first argument (a -> b) is a transformer function
- The second argument [a] is a list of a
- The return ...