{"action":"created","comment":{"url":"https://api.github.com/repos/plaid/sanctuary/pulls/comments/30526395","id":30526395,"diff_hunk":"@@ -1338,3 +1338,22 @@ describe('parse', function() {\n   });\n \n });\n+\n+describe('regex', function() {\n+\n+  describe('match', function() {\n+\n+    it('returns a Just if there is a match', function() {\n+      eq(S.match(/(good)?bye/, 'goodbye').toString(), 'Just([\"goodbye\", \"good\"])');\n+      eq(S.match(/([a-z]a)/g, 'bananas').toString(), 'Just([\"ba\", \"na\", \"na\"])');","path":"test/index.js","position":11,"original_position":11,"commit_id":"a1c66aa66b6796408e9c65788154ec82ac579f6d","original_commit_id":"a1c66aa66b6796408e9c65788154ec82ac579f6d","user":{"login":"davidchambers","id":210406,"avatar_url":"https://avatars.githubusercontent.com/u/210406?v=3","gravatar_id":"","url":"https://api.github.com/users/davidchambers","html_url":"https://github.com/davidchambers","followers_url":"https://api.github.com/users/davidchambers/followers","following_url":"https://api.github.com/users/davidchambers/following{/other_user}","gists_url":"https://api.github.com/users/davidchambers/gists{/gist_id}","starred_url":"https://api.github.com/users/davidchambers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidchambers/subscriptions","organizations_url":"https://api.github.com/users/davidchambers/orgs","repos_url":"https://api.github.com/users/davidchambers/repos","events_url":"https://api.github.com/users/davidchambers/events{/privacy}","received_events_url":"https://api.github.com/users/davidchambers/received_events","type":"User","site_admin":false},"body":"Nice pattern, though the capturing group is unnecessary. Capturing groups are ignored when the `g` flag is present.\r\n\r\nIt would be nice to separate these tests into different groups:\r\n\r\n```javascript\r\nit('returns a Just if there is a match', ...);\r\n\r\nit('returns a Nothing() if no match', ...);\r\n\r\nit('supports global patterns', ...);\r\n\r\nit('supports (optional) capturing groups', ...);\r\n```\r\n","created_at":"2015-05-18T17:00:36Z","updated_at":"2015-05-18T17:00:36Z","html_url":"https://github.com/plaid/sanctuary/pull/35#discussion_r30526395","pull_request_url":"https://api.github.com/repos/plaid/sanctuary/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/plaid/sanctuary/pulls/comments/30526395"},"html":{"href":"https://github.com/plaid/sanctuary/pull/35#discussion_r30526395"},"pull_request":{"href":"https://api.github.com/repos/plaid/sanctuary/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/plaid/sanctuary/pulls/35","id":35594064,"html_url":"https://github.com/plaid/sanctuary/pull/35","diff_url":"https://github.com/plaid/sanctuary/pull/35.diff","patch_url":"https://github.com/plaid/sanctuary/pull/35.patch","issue_url":"https://api.github.com/repos/plaid/sanctuary/issues/35","number":35,"state":"open","locked":false,"title":"Add S.match function","user":{"login":"svozza","id":8573472,"avatar_url":"https://avatars.githubusercontent.com/u/8573472?v=3","gravatar_id":"","url":"https://api.github.com/users/svozza","html_url":"https://github.com/svozza","followers_url":"https://api.github.com/users/svozza/followers","following_url":"https://api.github.com/users/svozza/following{/other_user}","gists_url":"https://api.github.com/users/svozza/gists{/gist_id}","starred_url":"https://api.github.com/users/svozza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svozza/subscriptions","organizations_url":"https://api.github.com/users/svozza/orgs","repos_url":"https://api.github.com/users/svozza/repos","events_url":"https://api.github.com/users/svozza/events{/privacy}","received_events_url":"https://api.github.com/users/svozza/received_events","type":"User","site_admin":false},"body":"Resolves #28 . I've actually been using R.compose with Sanctuary to create a safe version of `R.match` quite a few times recently so I thought I'd have a stab at a PR for this. The implementation is simple enough:\r\n\r\n```javascript\r\nS.match = R.curry(function (regex, s) {\r\n    return R.compose(S.toMaybe, R.match(regex))(s);\r\n  });\r\n```\r\n\r\nBut I was having problems writing the tests. Obviously because `R.match` returns an array, if I do something like:\r\n\r\n```javascript\r\nassert(S.match(/abcd/, 'abcdefg').equals(S.Just(['abcd']))\r\n```\r\n\r\nit fails because `Just.equals` is checking by reference.\r\n\r\nIf I do\r\n\r\n```javascript\r\nassert.deepEqual(S.match(/abcd/, str), S.Just(['abcd']));\r\n```\r\n\r\nit fails because `match` gives back this mad arraylike object with the object keys `input` and `index` so I find myself having to do this in the setup of the tests to get everything to work:\r\n\r\n```javascript\r\nvar str = 'abcdefg';\r\nvar search = /abcd/;\r\nvar result = ['abcd'];\r\nresult.index = 0;\r\nresult.input = 'abcdefg';\r\n...\r\nassert.deepEqual(S.match(search, str), S.Just(result));\r\n...\r\n//etc\r\n```\r\n\r\nIt feels a bit weird to do so but I'm not really able to think of alternatives. Any help would be appreciated.","created_at":"2015-05-17T21:54:04Z","updated_at":"2015-05-18T17:00:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b29b5d487ab459380df53b3289c20df74ed505b4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/plaid/sanctuary/pulls/35/commits","review_comments_url":"https://api.github.com/repos/plaid/sanctuary/pulls/35/comments","review_comment_url":"https://api.github.com/repos/plaid/sanctuary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plaid/sanctuary/issues/35/comments","statuses_url":"https://api.github.com/repos/plaid/sanctuary/statuses/a1c66aa66b6796408e9c65788154ec82ac579f6d","head":{"label":"svozza:safe-regex-match","ref":"safe-regex-match","sha":"a1c66aa66b6796408e9c65788154ec82ac579f6d","user":{"login":"svozza","id":8573472,"avatar_url":"https://avatars.githubusercontent.com/u/8573472?v=3","gravatar_id":"","url":"https://api.github.com/users/svozza","html_url":"https://github.com/svozza","followers_url":"https://api.github.com/users/svozza/followers","following_url":"https://api.github.com/users/svozza/following{/other_user}","gists_url":"https://api.github.com/users/svozza/gists{/gist_id}","starred_url":"https://api.github.com/users/svozza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svozza/subscriptions","organizations_url":"https://api.github.com/users/svozza/orgs","repos_url":"https://api.github.com/users/svozza/repos","events_url":"https://api.github.com/users/svozza/events{/privacy}","received_events_url":"https://api.github.com/users/svozza/received_events","type":"User","site_admin":false},"repo":{"id":34356599,"name":"sanctuary","full_name":"svozza/sanctuary","owner":{"login":"svozza","id":8573472,"avatar_url":"https://avatars.githubusercontent.com/u/8573472?v=3","gravatar_id":"","url":"https://api.github.com/users/svozza","html_url":"https://github.com/svozza","followers_url":"https://api.github.com/users/svozza/followers","following_url":"https://api.github.com/users/svozza/following{/other_user}","gists_url":"https://api.github.com/users/svozza/gists{/gist_id}","starred_url":"https://api.github.com/users/svozza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svozza/subscriptions","organizations_url":"https://api.github.com/users/svozza/orgs","repos_url":"https://api.github.com/users/svozza/repos","events_url":"https://api.github.com/users/svozza/events{/privacy}","received_events_url":"https://api.github.com/users/svozza/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/svozza/sanctuary","description":":see_no_evil: Refuge from unsafe JavaScript","fork":true,"url":"https://api.github.com/repos/svozza/sanctuary","forks_url":"https://api.github.com/repos/svozza/sanctuary/forks","keys_url":"https://api.github.com/repos/svozza/sanctuary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/svozza/sanctuary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/svozza/sanctuary/teams","hooks_url":"https://api.github.com/repos/svozza/sanctuary/hooks","issue_events_url":"https://api.github.com/repos/svozza/sanctuary/issues/events{/number}","events_url":"https://api.github.com/repos/svozza/sanctuary/events","assignees_url":"https://api.github.com/repos/svozza/sanctuary/assignees{/user}","branches_url":"https://api.github.com/repos/svozza/sanctuary/branches{/branch}","tags_url":"https://api.github.com/repos/svozza/sanctuary/tags","blobs_url":"https://api.github.com/repos/svozza/sanctuary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/svozza/sanctuary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/svozza/sanctuary/git/refs{/sha}","trees_url":"https://api.github.com/repos/svozza/sanctuary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/svozza/sanctuary/statuses/{sha}","languages_url":"https://api.github.com/repos/svozza/sanctuary/languages","stargazers_url":"https://api.github.com/repos/svozza/sanctuary/stargazers","contributors_url":"https://api.github.com/repos/svozza/sanctuary/contributors","subscribers_url":"https://api.github.com/repos/svozza/sanctuary/subscribers","subscription_url":"https://api.github.com/repos/svozza/sanctuary/subscription","commits_url":"https://api.github.com/repos/svozza/sanctuary/commits{/sha}","git_commits_url":"https://api.github.com/repos/svozza/sanctuary/git/commits{/sha}","comments_url":"https://api.github.com/repos/svozza/sanctuary/comments{/number}","issue_comment_url":"https://api.github.com/repos/svozza/sanctuary/issues/comments{/number}","contents_url":"https://api.github.com/repos/svozza/sanctuary/contents/{+path}","compare_url":"https://api.github.com/repos/svozza/sanctuary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/svozza/sanctuary/merges","archive_url":"https://api.github.com/repos/svozza/sanctuary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/svozza/sanctuary/downloads","issues_url":"https://api.github.com/repos/svozza/sanctuary/issues{/number}","pulls_url":"https://api.github.com/repos/svozza/sanctuary/pulls{/number}","milestones_url":"https://api.github.com/repos/svozza/sanctuary/milestones{/number}","notifications_url":"https://api.github.com/repos/svozza/sanctuary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/svozza/sanctuary/labels{/name}","releases_url":"https://api.github.com/repos/svozza/sanctuary/releases{/id}","created_at":"2015-04-21T23:00:05Z","updated_at":"2015-04-25T21:13:51Z","pushed_at":"2015-05-18T16:37:32Z","git_url":"git://github.com/svozza/sanctuary.git","ssh_url":"git@github.com:svozza/sanctuary.git","clone_url":"https://github.com/svozza/sanctuary.git","svn_url":"https://github.com/svozza/sanctuary","homepage":"","size":146,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"plaid:master","ref":"master","sha":"e479f926063df5a1a043b335b241b67d88664b97","user":{"login":"plaid","id":3579888,"avatar_url":"https://avatars.githubusercontent.com/u/3579888?v=3","gravatar_id":"","url":"https://api.github.com/users/plaid","html_url":"https://github.com/plaid","followers_url":"https://api.github.com/users/plaid/followers","following_url":"https://api.github.com/users/plaid/following{/other_user}","gists_url":"https://api.github.com/users/plaid/gists{/gist_id}","starred_url":"https://api.github.com/users/plaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plaid/subscriptions","organizations_url":"https://api.github.com/users/plaid/orgs","repos_url":"https://api.github.com/users/plaid/repos","events_url":"https://api.github.com/users/plaid/events{/privacy}","received_events_url":"https://api.github.com/users/plaid/received_events","type":"Organization","site_admin":false},"repo":{"id":29455960,"name":"sanctuary","full_name":"plaid/sanctuary","owner":{"login":"plaid","id":3579888,"avatar_url":"https://avatars.githubusercontent.com/u/3579888?v=3","gravatar_id":"","url":"https://api.github.com/users/plaid","html_url":"https://github.com/plaid","followers_url":"https://api.github.com/users/plaid/followers","following_url":"https://api.github.com/users/plaid/following{/other_user}","gists_url":"https://api.github.com/users/plaid/gists{/gist_id}","starred_url":"https://api.github.com/users/plaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plaid/subscriptions","organizations_url":"https://api.github.com/users/plaid/orgs","repos_url":"https://api.github.com/users/plaid/repos","events_url":"https://api.github.com/users/plaid/events{/privacy}","received_events_url":"https://api.github.com/users/plaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plaid/sanctuary","description":":see_no_evil: Refuge from unsafe JavaScript","fork":false,"url":"https://api.github.com/repos/plaid/sanctuary","forks_url":"https://api.github.com/repos/plaid/sanctuary/forks","keys_url":"https://api.github.com/repos/plaid/sanctuary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plaid/sanctuary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plaid/sanctuary/teams","hooks_url":"https://api.github.com/repos/plaid/sanctuary/hooks","issue_events_url":"https://api.github.com/repos/plaid/sanctuary/issues/events{/number}","events_url":"https://api.github.com/repos/plaid/sanctuary/events","assignees_url":"https://api.github.com/repos/plaid/sanctuary/assignees{/user}","branches_url":"https://api.github.com/repos/plaid/sanctuary/branches{/branch}","tags_url":"https://api.github.com/repos/plaid/sanctuary/tags","blobs_url":"https://api.github.com/repos/plaid/sanctuary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plaid/sanctuary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plaid/sanctuary/git/refs{/sha}","trees_url":"https://api.github.com/repos/plaid/sanctuary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plaid/sanctuary/statuses/{sha}","languages_url":"https://api.github.com/repos/plaid/sanctuary/languages","stargazers_url":"https://api.github.com/repos/plaid/sanctuary/stargazers","contributors_url":"https://api.github.com/repos/plaid/sanctuary/contributors","subscribers_url":"https://api.github.com/repos/plaid/sanctuary/subscribers","subscription_url":"https://api.github.com/repos/plaid/sanctuary/subscription","commits_url":"https://api.github.com/repos/plaid/sanctuary/commits{/sha}","git_commits_url":"https://api.github.com/repos/plaid/sanctuary/git/commits{/sha}","comments_url":"https://api.github.com/repos/plaid/sanctuary/comments{/number}","issue_comment_url":"https://api.github.com/repos/plaid/sanctuary/issues/comments{/number}","contents_url":"https://api.github.com/repos/plaid/sanctuary/contents/{+path}","compare_url":"https://api.github.com/repos/plaid/sanctuary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plaid/sanctuary/merges","archive_url":"https://api.github.com/repos/plaid/sanctuary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plaid/sanctuary/downloads","issues_url":"https://api.github.com/repos/plaid/sanctuary/issues{/number}","pulls_url":"https://api.github.com/repos/plaid/sanctuary/pulls{/number}","milestones_url":"https://api.github.com/repos/plaid/sanctuary/milestones{/number}","notifications_url":"https://api.github.com/repos/plaid/sanctuary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plaid/sanctuary/labels{/name}","releases_url":"https://api.github.com/repos/plaid/sanctuary/releases{/id}","created_at":"2015-01-19T05:52:10Z","updated_at":"2015-05-14T17:30:53Z","pushed_at":"2015-05-18T16:37:33Z","git_url":"git://github.com/plaid/sanctuary.git","ssh_url":"git@github.com:plaid/sanctuary.git","clone_url":"https://github.com/plaid/sanctuary.git","svn_url":"https://github.com/plaid/sanctuary","homepage":"","size":747,"stargazers_count":31,"watchers_count":31,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":4,"forks":2,"open_issues":4,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plaid/sanctuary/pulls/35"},"html":{"href":"https://github.com/plaid/sanctuary/pull/35"},"issue":{"href":"https://api.github.com/repos/plaid/sanctuary/issues/35"},"comments":{"href":"https://api.github.com/repos/plaid/sanctuary/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/plaid/sanctuary/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/plaid/sanctuary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plaid/sanctuary/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/plaid/sanctuary/statuses/a1c66aa66b6796408e9c65788154ec82ac579f6d"}}}}