Define an instance for Show for a Keyboard
This will help me debug.
This commit is contained in:
parent
1af0007a7d
commit
d948ed9ebf
1 changed files with 23 additions and 0 deletions
23
scratch/brilliant/Keyboard.hs
Normal file
23
scratch/brilliant/Keyboard.hs
Normal file
|
@ -0,0 +1,23 @@
|
|||
--------------------------------------------------------------------------------
|
||||
module Keyboard where
|
||||
--------------------------------------------------------------------------------
|
||||
import Utils
|
||||
import qualified Data.List as List
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
newtype Keyboard = Keyboard [[Char]]
|
||||
|
||||
instance Show Keyboard where
|
||||
show (Keyboard xxs) =
|
||||
xxs |> fmap printRow |> List.intercalate "\n"
|
||||
where
|
||||
printRow :: [Char] -> String
|
||||
printRow xs =
|
||||
xs |> fmap (\x -> '[':x:']':"") |> List.intercalate ""
|
||||
|
||||
qwerty :: Keyboard
|
||||
qwerty = Keyboard [ ['1','2','3','4','5','6','7','8','9','0']
|
||||
, ['Q','W','E','R','T','Y','U','I','O','P']
|
||||
, ['A','S','D','F','G','H','J','K','L',';']
|
||||
, ['Z','X','C','V','B','N','M',',','.','/']
|
||||
]
|
Loading…
Reference in a new issue