Is it possible to convert an IO type to an arbitrary one?

I was building a Sudoku solution in Haskell, and I have two functions:

genProblemm :: Node -> IO Node
newSudoku   :: IO Node

to create sudoku puzzles. I would like to use the library QuickCheckto test my solver. Is it possible to make an Nodeinstance Arbitraryusing these functions? I could not find a common way ...

I just got to type:

instance Arbitrary Node where
  arbitrary = 

... but I don't know how to write Arbitraryusing my existing functions, which are types IO.

edits:

Node = (Sudoku, [(Column, Row, [Int])])
type Sudoku = (Row,Column) -> Int

A Node - All Sudoku.

+4
source share

All Articles