我正在尝试编写一个更改数独的道具,然后检查它是否仍然有效。
但是,我不确定如何正确使用“oneof”功能。请给我一些提示好吗?
prop_candidates :: Sudoku -> Bool
prop_candidates su = isSudoku newSu && isOkay newSu
where
newSu = update su aBlank aCandidate
aCandidate = oneof [return x | x <- candidates su aBlank]
aBlank = oneof [return x | x <- (blanks su)]
这里有更多信息...
type Pos = (Int, Int)
update :: Sudoku -> Pos -> Maybe Int -> Sudoku
blanks :: Sudoku -> [Pos]
candidates :: Sudoku -> Pos -> [Int]
[return x | x <- (blanks example)] :: (Monad m) => [m Pos]
我已经为这个道具奋斗了 3 个小时,所以欢迎任何想法!