{"action":"closed","issue":{"url":"https://api.github.com/repos/CIFASIS/QuickFuzz/issues/12","labels_url":"https://api.github.com/repos/CIFASIS/QuickFuzz/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/CIFASIS/QuickFuzz/issues/12/comments","events_url":"https://api.github.com/repos/CIFASIS/QuickFuzz/issues/12/events","html_url":"https://github.com/CIFASIS/QuickFuzz/issues/12","id":116906285,"number":12,"title":"Arbitrary instance for Image is problematic","user":{"login":"ayberkt","id":3195012,"avatar_url":"https://avatars.githubusercontent.com/u/3195012?v=3","gravatar_id":"","url":"https://api.github.com/users/ayberkt","html_url":"https://github.com/ayberkt","followers_url":"https://api.github.com/users/ayberkt/followers","following_url":"https://api.github.com/users/ayberkt/following{/other_user}","gists_url":"https://api.github.com/users/ayberkt/gists{/gist_id}","starred_url":"https://api.github.com/users/ayberkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayberkt/subscriptions","organizations_url":"https://api.github.com/users/ayberkt/orgs","repos_url":"https://api.github.com/users/ayberkt/repos","events_url":"https://api.github.com/users/ayberkt/events{/privacy}","received_events_url":"https://api.github.com/users/ayberkt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-14T06:59:09Z","updated_at":"2015-12-02T12:20:27Z","closed_at":"2015-12-02T12:20:27Z","body":"The `Arbitrary` instance declaration for ``Image PixelRGBA8`` is as follows:\r\n```haskell\r\ninstance Arbitrary (Image PixelRGBA8) where\r\n   arbitrary = do\r\n       l <- listOf (arbitrary :: Gen Word8)\r\n       w <- (arbitrary :: Gen Int)\r\n       h <- (arbitrary :: Gen Int)\r\n       return $ Image { imageWidth = w, imageHeight = h, imageData = VS.fromList l }\r\n```\r\nThe width, height, and the length of the data vector for the image have to be consistent with each other. This declaration results in QuickCheck causing an `OutOfBounds` exception. Moreover width and height have to be constrained to have positive values, which is trivial to fix. But I am not sure how to keep image parameters consistent with each other. One quick fix I implemented was to arbitarily choose `l` and `w` and then set `h` based on those two. But then the image array has to be constrained to have a length divisible by 4 (in the case of PixelRGBA8). I am not really experienced with QuickCheck so there probably is a better way of doing this."}}