aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/KeySequence.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-27 17:54:31 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-27 17:54:31 +0530
commit98af698a806e41904368c0114f9d8d9f377d9c09 (patch)
treeb09e835b1cf4c678fe557b1ab01905e75ee3922f /src/Chelleport/KeySequence.hs
parent3d461b234d0b30cb7085251390b264089f447a97 (diff)
downloadchelleport-98af698a806e41904368c0114f9d8d9f377d9c09.tar.gz
chelleport-98af698a806e41904368c0114f9d8d9f377d9c09.zip
Minor refactor
Diffstat (limited to 'src/Chelleport/KeySequence.hs')
-rw-r--r--src/Chelleport/KeySequence.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Chelleport/KeySequence.hs b/src/Chelleport/KeySequence.hs
index 70d56e2..141e71e 100644
--- a/src/Chelleport/KeySequence.hs
+++ b/src/Chelleport/KeySequence.hs
@@ -37,10 +37,10 @@ lcg seed = (multiplier * seed + increment) `mod` modulus
getIndexRounded :: Int -> [a] -> a
getIndexRounded i ls = ls !! (i `mod` length ls)
-generateGrid :: Int -> (Int, Int) -> KeySequence -> Maybe KeyGrid
+generateGrid :: Int -> (Int, Int) -> KeySequence -> Either String KeyGrid
generateGrid seed (rows, columns) hintKeys
- | rows * columns > length hintKeys * length hintKeys = Nothing
- | otherwise = Just $ (\row -> getKeySeq row <$> [0 .. columns - 1]) <$> [0 .. rows - 1]
+ | rows * columns >= length hintKeys * length hintKeys = Left "Row/Column counts too high"
+ | otherwise = Right $ (\row -> getKeySeq row <$> [0 .. columns - 1]) <$> [0 .. rows - 1]
where
allKeySeq = take numPairs . uniq $ generatePairs
numPairs = rows * columns