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-12 13:03:35 +02:00
|
|
|
import qualified Data.List.Split as Split
|
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
|
2020-08-12 13:03:35 +02:00
|
|
|
|
|
|
|
transform (Keyboard xs) xform =
|
|
|
|
case xform of
|
|
|
|
HorizontalFlip ->
|
|
|
|
xs
|
|
|
|
|> fmap reverse
|
|
|
|
|> Keyboard
|
|
|
|
|
|
|
|
VerticalFlip ->
|
|
|
|
xs
|
|
|
|
|> reverse
|
|
|
|
|> Keyboard
|
|
|
|
|
|
|
|
Shift n ->
|
|
|
|
xs
|
|
|
|
|> concat
|
|
|
|
|> Utils.rotate n
|
|
|
|
|> Split.chunksOf 10
|
|
|
|
|> 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)
|