I am trying to implement my own version of the reverse function in Haskell. The following code utilizing the : operator.
reverse' :: [a] -> [a]
reverse' [] = []
reverse' (x:xs) = reverse' xs : [x]
This results in the a compilation error. However, if I use the ++ operator instead, the code compiles without issue. This is demonstrated here:
reverse' :: [a] -> [a]
reverse' [] = []
reverse' (x:xs) = reverse' xs ++ [x]
Why doesn't the : operator work here?