- Change directory to reverse, and open src/Main.hs. This file defines the Main module.
- Conditionally import Prelude, hiding the reverse function:
import Prelude hiding (reverse)
Note that Prelude is imported automatically unless it is explicitly imported. Since we will write our own reverse function, we need to hide the reverse function while importing Prelude.
- Write the signature of a reverse function:
reverse :: [a] -> [a]
This function takes a list of any type, a, and returns the reversed list.
- Implement the reverse function using recursion:
reverse :: [a] -> [a] reverse xs = reverse' xs  where reverse' :: [a] -> [a] -> [a] reverse'  rs = rs reverse' (x:xs) rs = reverse' xs (x:rs)
Note that we have a written ...