2020-08-06 00:20:18 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
module App where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Keyboard (Keyboard(..))
|
|
|
|
import Transforms (Transform(..))
|
|
|
|
import Utils ((|>))
|
|
|
|
|
2020-08-06 01:18:44 +02:00
|
|
|
import qualified Data.Char as Char
|
2020-08-06 00:20:18 +02:00
|
|
|
import qualified Utils
|
2020-08-06 01:18:44 +02:00
|
|
|
import qualified Keyboard
|
|
|
|
import qualified Data.HashMap.Strict as HM
|
2020-08-06 00:20:18 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2020-08-06 00:30:25 +02:00
|
|
|
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
|
2020-08-06 01:18:44 +02:00
|
|
|
|
|
|
|
retypePassage :: String -> Keyboard -> Maybe String
|
|
|
|
retypePassage passage newKeyboard =
|
|
|
|
passage
|
|
|
|
|> fmap Char.toUpper
|
|
|
|
|> traverse (\c -> HM.lookup c Keyboard.charToCoord)
|
|
|
|
>>= traverse (Keyboard.coordToChar newKeyboard)
|