I started learning Haskell a couple of days ago and decided to build a Caesar shift in it.
import Data.Char
shift_str :: Int -> ([Char] -> [Char])
shift_str num
| num > 1 = \str -> shift_str_forwards (shift_str (num-1) str)
| num == 1 = shift_str_forwards
| num == 0 = no_shift
| num == -1 = shift_str_backwards
| num < -1 = \str -> shift_str_backwards (shift_str (num+1) str)
no_shift :: [Char] -> [Char]
no_shift str = str
shift_str_forwards :: [Char] -> [Char]
shift_str_forwards str = map shift_forwards str
shift_str_backwards :: [Char] -> [Char]
shift_str_backwards str = map shift_backwards str
shift_forwards :: Char -> Char
shift_forwards char
| char == 'z' = 'a'
| otherwise = chr (1 + ord char)
shift_backwards :: Char -> Char
shift_backwards char
| char == 'a' = 'z'
| otherwise = chr (ord char - 1)
However, this seems far too complex to be the right way of doing it. Any advice?