{"action":"created","issue":{"url":"https://api.github.com/repos/jsverify/jsverify/issues/135","labels_url":"https://api.github.com/repos/jsverify/jsverify/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/jsverify/jsverify/issues/135/comments","events_url":"https://api.github.com/repos/jsverify/jsverify/issues/135/events","html_url":"https://github.com/jsverify/jsverify/issues/135","id":104290877,"number":135,"title":".sum woes","user":{"login":"dmitriid","id":32768,"avatar_url":"https://avatars.githubusercontent.com/u/32768?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitriid","html_url":"https://github.com/dmitriid","followers_url":"https://api.github.com/users/dmitriid/followers","following_url":"https://api.github.com/users/dmitriid/following{/other_user}","gists_url":"https://api.github.com/users/dmitriid/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitriid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitriid/subscriptions","organizations_url":"https://api.github.com/users/dmitriid/orgs","repos_url":"https://api.github.com/users/dmitriid/repos","events_url":"https://api.github.com/users/dmitriid/events{/privacy}","received_events_url":"https://api.github.com/users/dmitriid/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jsverify/jsverify/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/jsverify/jsverify/labels/documentation","name":"documentation","color":"207de5"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-01T15:23:31Z","updated_at":"2015-09-02T13:24:29Z","closed_at":"2015-09-02T13:02:23Z","body":"Disclaimer: I may be using this incorrectly :)\r\n\r\n## Doc update\r\n\r\nCurrently it reads: \r\n\r\n> \"bool | nat\" is evaluated to jsc.sum(jsc.bool, jsc.nat)\r\n\r\nShould read\r\n\r\n> \"bool | nat\" is evaluated to jsc.sum([jsc.bool, jsc.nat])\r\n\r\nAs the `.sum` accepts a list of generators (I think).\r\n\r\n## Usage\r\n\r\nThe reason I think it should be a list of generators\r\n```node\r\n> (jsc.sampler(jsc.array(jsc.sum(jsc.nat, jsc.string))))()\r\nTypeError: undefined is not a function\r\n```\r\n\r\nGenerates an array of `sum`s(?) instead of an array of values\r\n\r\n```node\r\n> (jsc.sampler(jsc.array(jsc.sum([jsc.nat, jsc.string]))))()\r\n[ { idx: 0, len: 2, value: 4 }, { idx: 1, len: 2, value: '' } ]\r\n```\r\n\r\nAs a result you may get a very cryptic message:\r\n\r\n```node\r\n// Given\r\njsc.property('test', 'array(nat | string)', (arr) => { ....\r\n\r\n// May result in something like\r\nError: ... Counterexample: [Sum(1/2: \"\")];\r\n```"},"comment":{"url":"https://api.github.com/repos/jsverify/jsverify/issues/comments/137077581","html_url":"https://github.com/jsverify/jsverify/issues/135#issuecomment-137077581","issue_url":"https://api.github.com/repos/jsverify/jsverify/issues/135","id":137077581,"user":{"login":"phadej","id":51087,"avatar_url":"https://avatars.githubusercontent.com/u/51087?v=3","gravatar_id":"","url":"https://api.github.com/users/phadej","html_url":"https://github.com/phadej","followers_url":"https://api.github.com/users/phadej/followers","following_url":"https://api.github.com/users/phadej/following{/other_user}","gists_url":"https://api.github.com/users/phadej/gists{/gist_id}","starred_url":"https://api.github.com/users/phadej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phadej/subscriptions","organizations_url":"https://api.github.com/users/phadej/orgs","repos_url":"https://api.github.com/users/phadej/repos","events_url":"https://api.github.com/users/phadej/events{/privacy}","received_events_url":"https://api.github.com/users/phadej/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T13:24:29Z","updated_at":"2015-09-02T13:24:29Z","body":"`either` is `sum` with two (and always two) \"options\" (addends). Thus `either` doesn't take array. Same as with `pair`  and `tuple`: pair is two-tuple, either is two-sum."}}