{"action":"created","issue":{"url":"https://api.github.com/repos/rickynils/scalacheck/issues/272","repository_url":"https://api.github.com/repos/rickynils/scalacheck","labels_url":"https://api.github.com/repos/rickynils/scalacheck/issues/272/labels{/name}","comments_url":"https://api.github.com/repos/rickynils/scalacheck/issues/272/comments","events_url":"https://api.github.com/repos/rickynils/scalacheck/issues/272/events","html_url":"https://github.com/rickynils/scalacheck/pull/272","id":181560699,"number":272,"title":"CogenSpecification","user":{"login":"adamgfraser","id":20825463,"avatar_url":"https://avatars.githubusercontent.com/u/20825463?v=3","gravatar_id":"","url":"https://api.github.com/users/adamgfraser","html_url":"https://github.com/adamgfraser","followers_url":"https://api.github.com/users/adamgfraser/followers","following_url":"https://api.github.com/users/adamgfraser/following{/other_user}","gists_url":"https://api.github.com/users/adamgfraser/gists{/gist_id}","starred_url":"https://api.github.com/users/adamgfraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamgfraser/subscriptions","organizations_url":"https://api.github.com/users/adamgfraser/orgs","repos_url":"https://api.github.com/users/adamgfraser/repos","events_url":"https://api.github.com/users/adamgfraser/events{/privacy}","received_events_url":"https://api.github.com/users/adamgfraser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-07T01:02:13Z","updated_at":"2016-10-17T00:30:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rickynils/scalacheck/pulls/272","html_url":"https://github.com/rickynils/scalacheck/pull/272","diff_url":"https://github.com/rickynils/scalacheck/pull/272.diff","patch_url":"https://github.com/rickynils/scalacheck/pull/272.patch"},"body":"This proposal creates a new test suite for Cogen. The tests are based on the concept that Cogen instances should satisfy two properties:\r\n\r\n**1. Consistency** - A given Cogen should always return the same output for the same seed and input. In other words, Cogen is referentially transparent.\r\n**2. Uniqueness** - Given a seed, a Cogen should always return different outputs for inputs that are not equal. One can imagine a Cogen that does not do this (e.g. one that is only based on the length of a string to a model a function that only uses that information), but especially for Cogen instances that will generally be available implicitly this seems like a highly desirable property.\r\n\r\nWith a few minor provisions, all of the existing Cogen instances satisfy these laws. In the case of Function0, Array, Throwable, and Exception we need to use a different definition of equality than the standard `==` but these are fine. For BigDecimal there is a corner case where `BigDecimal(0, Int.MaxValue) == BigDecimal(0, Int.MinValue)` evaluates to true but the Cogen instances returns different values. Not quite sure how to handle that.\r\n\r\nI also made a couple of minor changes to the code for Cogen itself. First, I removed the call to `.next` on constructing a new Cogen. I don't think this is necessary and by removing it we can establish several other nice laws for Cogen. Specifically, `contramap(a => a)` is now an identity function consistent with the laws for contravariant functors. Also, we can show that Cogen forms a Monoid and a Divisible (the contravariant equivalent of an Applicative). Hopefully this is not too much category theory but this does provide some additional ways to compose Cogen if someone wants to go down the road of creating more sophisticated arbitrary functions and provides some laws to reason about them.\r\n\r\nThis is my first pull request so open to any and all feedback. Hopefully this is helpful."},"comment":{"url":"https://api.github.com/repos/rickynils/scalacheck/issues/comments/254088269","html_url":"https://github.com/rickynils/scalacheck/pull/272#issuecomment-254088269","issue_url":"https://api.github.com/repos/rickynils/scalacheck/issues/272","id":254088269,"user":{"login":"adamgfraser","id":20825463,"avatar_url":"https://avatars.githubusercontent.com/u/20825463?v=3","gravatar_id":"","url":"https://api.github.com/users/adamgfraser","html_url":"https://github.com/adamgfraser","followers_url":"https://api.github.com/users/adamgfraser/followers","following_url":"https://api.github.com/users/adamgfraser/following{/other_user}","gists_url":"https://api.github.com/users/adamgfraser/gists{/gist_id}","starred_url":"https://api.github.com/users/adamgfraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamgfraser/subscriptions","organizations_url":"https://api.github.com/users/adamgfraser/orgs","repos_url":"https://api.github.com/users/adamgfraser/repos","events_url":"https://api.github.com/users/adamgfraser/events{/privacy}","received_events_url":"https://api.github.com/users/adamgfraser/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T00:30:02Z","updated_at":"2016-10-17T00:30:02Z","body":"Hmmm, interesting. I didn't get that error message when I ran the tests locally. Hopefully making Cogen invariant will resolve it. I'm trying to get more involved with community projects so let me know if there is anything else you're looking for help with."}}
{"actor":{"display_login":"adamgfraser"}}