Support App.transform

Apply the transform to a Keyboard. Onwards to the final demonstration!
This commit is contained in:
William Carroll 2020-08-05 23:20:18 +01:00
parent 61a2fb108d
commit 244503bba9
5 changed files with 57 additions and 1 deletions

14
scratch/brilliant/App.hs Normal file
View file

@ -0,0 +1,14 @@
--------------------------------------------------------------------------------
module App where
--------------------------------------------------------------------------------
import Keyboard (Keyboard(..))
import Transforms (Transform(..))
import Utils ((|>))
import qualified Utils
--------------------------------------------------------------------------------
transform :: Transform -> Keyboard -> Keyboard
transform HorizontalFlip (Keyboard xs) = xs |> fmap reverse |> Keyboard
transform VerticalFlip (Keyboard xs) = xs |> reverse |> Keyboard
transform (Shift n) (Keyboard xs) = xs |> fmap (Utils.rotate n) |> Keyboard