+module Main(main) where
+
import Data.Array.IArray
-- Row 1 is top, column 1 is left
type Position = (Int, Int)
type Keyboard = Array Position Char
-kb1 = [['x', 'x', 'x', 'x', 'x'],
- ['x', '1', '2', '3', 'x'],
- ['x', '4', '5', '6', 'x'],
- ['x', '7', '8', '9', 'x'],
- ['x', 'x', 'x', 'x', 'x']]
+kb1 = ["xxxxx",
+ "x123x",
+ "x456x",
+ "x789x",
+ "xxxxx"]
kb2 = ["xxxxxxx",
"xxx1xxx",
enumerate = zip [0..]
mkKeyboard :: [String] -> Keyboard
-mkKeyboard kb = array ((0, 0), (length kb - 1, length kb - 1))
+mkKeyboard kb = array ((0, 0), (length kb - 1, length (kb!!0) - 1))
[((i, j), c) | (i, r) <- enumerate kb, (j, c) <- enumerate r]
keyboard1 = mkKeyboard kb1