{-| Module : Data.Caesar Description : Utilities for doing caesar transforms Copyright : (c) Mats Rauhala, 2019 License : BSD3 Maintainer : mats.rauhala@iki.fi Stability : experimental Portability : POSIX -} module Data.Caesar where -- | Type alias over char type Caesar = Char -- | Translate to the next character on the left -- -- Has special handling for some symbols next :: Char -> Char next c = case c of '.' -> '.' ' ' -> ' ' 'ö' -> 'ä' 'ä' -> 'å' 'å' -> 'z' 'a' -> 'ö' x -> pred x -- | Translate a character n times caesar :: Int -> Caesar -> Caesar caesar n x = foldr ($) x (replicate n next)