Re-type type using the altered keyboard

Remember: always read the instructions; that's the most important part.
This commit is contained in:
William Carroll 2020-08-06 00:18:44 +01:00
parent e14fff7d4b
commit 5f52077492
5 changed files with 129 additions and 7 deletions

View file

@ -5,10 +5,20 @@ import Keyboard (Keyboard(..))
import Transforms (Transform(..))
import Utils ((|>))
import qualified Data.Char as Char
import qualified Utils
import qualified Keyboard
import qualified Data.HashMap.Strict as HM
--------------------------------------------------------------------------------
transform :: Keyboard -> Transform -> Keyboard
transform (Keyboard xs) HorizontalFlip = xs |> fmap reverse |> Keyboard
transform (Keyboard xs) VerticalFlip = xs |> reverse |> Keyboard
transform (Keyboard xs) (Shift n) = xs |> fmap (Utils.rotate n) |> Keyboard
retypePassage :: String -> Keyboard -> Maybe String
retypePassage passage newKeyboard =
passage
|> fmap Char.toUpper
|> traverse (\c -> HM.lookup c Keyboard.charToCoord)
>>= traverse (Keyboard.coordToChar newKeyboard)