Skip to content

Instantly share code, notes, and snippets.

@dorchard
Last active August 30, 2016 05:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorchard/7ed17c66677a64d069ff to your computer and use it in GitHub Desktop.
Save dorchard/7ed17c66677a64d069ff to your computer and use it in GitHub Desktop.
My QuickCheck instance for Data.Matrix (square matrices)
instance (Arbitrary a) => Arbitrary (Matrix a) where
-- NB: for square matrices
arbitrary = sized (\n -> do xs <- vectorOf (n*n) arbitrary
return $ matrix n n (\(i, j) -> xs !! ((i-1)*n + (j-1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment