From 98af698a806e41904368c0114f9d8d9f377d9c09 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 27 Dec 2024 17:54:31 +0530 Subject: Minor refactor --- src/Chelleport/KeySequence.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Chelleport/KeySequence.hs') 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 -- cgit v1.3.1