-- Speed this up by keeping row/column/diagonal sums locally.
chessMoveCounter :: (Integer -> Integer -> [(Integer, Integer)]) -> Integer -> Integer -> Integer
chessMoveCounter f = memoizedCounter where
    memoizedCounter = memo2 integral integral computer where
        computer 0 _ = 0
        computer _ 0 = 0
        computer 1 1 = 1
        computer n k = sum $ map (uncurry memoizedCounter) $ f n k
chessMoveCounter :: (Integer -> Integer -> [(Integer, Integer)]) -> Integer -> Integer -> Integer
chessMoveCounter f = memoizedCounter where
    memoizedCounter = memo2 integral integral computer where
        computer 0 _ = 0
        computer _ 0 = 0
        computer 1 1 = 1
        computer n k = sum $ map (uncurry memoizedCounter) $ f n k
chessMoveCounter f = memoizedCounter where
    memoizedCounter = memo2 integral integral computer where
        computer 0 _ = 0
        computer _ 0 = 0
        computer 1 1 = 1
        computer n k = sum $ map (uncurry memoizedCounter) $ f n k