{"action":"created","comment":{"url":"https://api.github.com/repos/robrix/Either/pulls/comments/27777080","id":27777080,"diff_hunk":"@@ -96,6 +96,38 @@ public func >>- <T, U, V> (either: Either<T, U>, @noescape transform: U -> Eithe\n }\n \n \n+///  Extracts from a list of `Either` all the `Left` elements. All the `Left` elements are extracted in order.\n+public func lefts <T, U>(list: [Either<T, U>]) -> [T] {\n+\treturn list.reduce([T]()) { ( var memo, e) in\n+\t\tif let l = e.left {\n+\t\t\tmemo.append(l)\n+\t\t}\n+\t\t\n+\t\treturn memo\n+\t}\n+}\n+\n+\n+///  Extracts from a list of `Either` all the `Right` elements. All the `Right` elements are extracted in order.\n+public func rights <T, U>(list: [Either<T, U>]) -> [U] {\n+\treturn list.reduce([U]()) { ( var memo, e) in\n+\t\tif let l = e.right {\n+\t\t\tmemo.append(l)\n+\t\t}\n+\t\t\n+\t\treturn memo\n+\t}\n+}\n+\n+\n+///  Partitions a list of `Either` into two lists.\n+///\n+///  All the `Left` elements are extracted in order to the first component of the output. The `Right` elemests are extracted in order to the second component of the output.\n+public func partitionEithers <T, U>(list: [Either<T, U>]) -> ([T], [U]) {\n+\treturn (lefts(list), rights(list))\n+}","path":"Either/Either.swift","position":33,"original_position":33,"commit_id":"b556c2d0e9e6c643affb4fa941fa8141e3b61003","original_commit_id":"b556c2d0e9e6c643affb4fa941fa8141e3b61003","user":{"login":"robrix","id":59671,"avatar_url":"https://avatars.githubusercontent.com/u/59671?v=3","gravatar_id":"","url":"https://api.github.com/users/robrix","html_url":"https://github.com/robrix","followers_url":"https://api.github.com/users/robrix/followers","following_url":"https://api.github.com/users/robrix/following{/other_user}","gists_url":"https://api.github.com/users/robrix/gists{/gist_id}","starred_url":"https://api.github.com/users/robrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robrix/subscriptions","organizations_url":"https://api.github.com/users/robrix/orgs","repos_url":"https://api.github.com/users/robrix/repos","events_url":"https://api.github.com/users/robrix/events{/privacy}","received_events_url":"https://api.github.com/users/robrix/received_events","type":"User","site_admin":true},"body":"Some questions:\r\n\r\n1. What do you think about making these `static` functions on `Either` instead of free functions?\r\n\r\n2. Alternatively, what do you think about implementing them as free functions over `EitherType` instead of over `Either`?\r\n\r\n3. Would it make sense to implement `lefts`/`rights` over arbitrary `SequenceType` instead of requiring `Array`? If we do decide thus, could you please adjust the docs & parameters to `sequence` instead of `list`?\r\n\r\n4. Would it make sense to use `SequenceOf`, `FilterSequenceView`, or `MapSequenceView` to make the result lazy?","created_at":"2015-04-05T12:50:38Z","updated_at":"2015-04-05T12:50:38Z","html_url":"https://github.com/robrix/Either/pull/25#discussion_r27777080","pull_request_url":"https://api.github.com/repos/robrix/Either/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/robrix/Either/pulls/comments/27777080"},"html":{"href":"https://github.com/robrix/Either/pull/25#discussion_r27777080"},"pull_request":{"href":"https://api.github.com/repos/robrix/Either/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/robrix/Either/pulls/25","id":32647715,"html_url":"https://github.com/robrix/Either/pull/25","diff_url":"https://github.com/robrix/Either/pull/25.diff","patch_url":"https://github.com/robrix/Either/pull/25.patch","issue_url":"https://api.github.com/repos/robrix/Either/issues/25","number":25,"state":"open","locked":false,"title":"Add `lefts`, `rights` and `partitionEithers` functions to Either","user":{"login":"Abizern","id":6902,"avatar_url":"https://avatars.githubusercontent.com/u/6902?v=3","gravatar_id":"","url":"https://api.github.com/users/Abizern","html_url":"https://github.com/Abizern","followers_url":"https://api.github.com/users/Abizern/followers","following_url":"https://api.github.com/users/Abizern/following{/other_user}","gists_url":"https://api.github.com/users/Abizern/gists{/gist_id}","starred_url":"https://api.github.com/users/Abizern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Abizern/subscriptions","organizations_url":"https://api.github.com/users/Abizern/orgs","repos_url":"https://api.github.com/users/Abizern/repos","events_url":"https://api.github.com/users/Abizern/events{/privacy}","received_events_url":"https://api.github.com/users/Abizern/received_events","type":"User","site_admin":false},"body":"`lefts`, `rights`, and `partitionEithers` are defined in Haskell's\r\nData.Either. These are useful methods to have when mapping a function\r\nthat returns Either values over a list. Such as parsing JSON.","created_at":"2015-04-05T11:55:48Z","updated_at":"2015-04-05T12:50:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6fc33cab20a2f44c90402b3a37c544e0d514d0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/robrix/Either/pulls/25/commits","review_comments_url":"https://api.github.com/repos/robrix/Either/pulls/25/comments","review_comment_url":"https://api.github.com/repos/robrix/Either/pulls/comments{/number}","comments_url":"https://api.github.com/repos/robrix/Either/issues/25/comments","statuses_url":"https://api.github.com/repos/robrix/Either/statuses/b556c2d0e9e6c643affb4fa941fa8141e3b61003","head":{"label":"JungleCandy:lists","ref":"lists","sha":"b556c2d0e9e6c643affb4fa941fa8141e3b61003","user":{"login":"JungleCandy","id":8014687,"avatar_url":"https://avatars.githubusercontent.com/u/8014687?v=3","gravatar_id":"","url":"https://api.github.com/users/JungleCandy","html_url":"https://github.com/JungleCandy","followers_url":"https://api.github.com/users/JungleCandy/followers","following_url":"https://api.github.com/users/JungleCandy/following{/other_user}","gists_url":"https://api.github.com/users/JungleCandy/gists{/gist_id}","starred_url":"https://api.github.com/users/JungleCandy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JungleCandy/subscriptions","organizations_url":"https://api.github.com/users/JungleCandy/orgs","repos_url":"https://api.github.com/users/JungleCandy/repos","events_url":"https://api.github.com/users/JungleCandy/events{/privacy}","received_events_url":"https://api.github.com/users/JungleCandy/received_events","type":"Organization","site_admin":false},"repo":{"id":33378649,"name":"Either","full_name":"JungleCandy/Either","owner":{"login":"JungleCandy","id":8014687,"avatar_url":"https://avatars.githubusercontent.com/u/8014687?v=3","gravatar_id":"","url":"https://api.github.com/users/JungleCandy","html_url":"https://github.com/JungleCandy","followers_url":"https://api.github.com/users/JungleCandy/followers","following_url":"https://api.github.com/users/JungleCandy/following{/other_user}","gists_url":"https://api.github.com/users/JungleCandy/gists{/gist_id}","starred_url":"https://api.github.com/users/JungleCandy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JungleCandy/subscriptions","organizations_url":"https://api.github.com/users/JungleCandy/orgs","repos_url":"https://api.github.com/users/JungleCandy/repos","events_url":"https://api.github.com/users/JungleCandy/events{/privacy}","received_events_url":"https://api.github.com/users/JungleCandy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JungleCandy/Either","description":"Swift µframework of Either, which represents two alternatives.","fork":true,"url":"https://api.github.com/repos/JungleCandy/Either","forks_url":"https://api.github.com/repos/JungleCandy/Either/forks","keys_url":"https://api.github.com/repos/JungleCandy/Either/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JungleCandy/Either/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JungleCandy/Either/teams","hooks_url":"https://api.github.com/repos/JungleCandy/Either/hooks","issue_events_url":"https://api.github.com/repos/JungleCandy/Either/issues/events{/number}","events_url":"https://api.github.com/repos/JungleCandy/Either/events","assignees_url":"https://api.github.com/repos/JungleCandy/Either/assignees{/user}","branches_url":"https://api.github.com/repos/JungleCandy/Either/branches{/branch}","tags_url":"https://api.github.com/repos/JungleCandy/Either/tags","blobs_url":"https://api.github.com/repos/JungleCandy/Either/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JungleCandy/Either/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JungleCandy/Either/git/refs{/sha}","trees_url":"https://api.github.com/repos/JungleCandy/Either/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JungleCandy/Either/statuses/{sha}","languages_url":"https://api.github.com/repos/JungleCandy/Either/languages","stargazers_url":"https://api.github.com/repos/JungleCandy/Either/stargazers","contributors_url":"https://api.github.com/repos/JungleCandy/Either/contributors","subscribers_url":"https://api.github.com/repos/JungleCandy/Either/subscribers","subscription_url":"https://api.github.com/repos/JungleCandy/Either/subscription","commits_url":"https://api.github.com/repos/JungleCandy/Either/commits{/sha}","git_commits_url":"https://api.github.com/repos/JungleCandy/Either/git/commits{/sha}","comments_url":"https://api.github.com/repos/JungleCandy/Either/comments{/number}","issue_comment_url":"https://api.github.com/repos/JungleCandy/Either/issues/comments{/number}","contents_url":"https://api.github.com/repos/JungleCandy/Either/contents/{+path}","compare_url":"https://api.github.com/repos/JungleCandy/Either/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JungleCandy/Either/merges","archive_url":"https://api.github.com/repos/JungleCandy/Either/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JungleCandy/Either/downloads","issues_url":"https://api.github.com/repos/JungleCandy/Either/issues{/number}","pulls_url":"https://api.github.com/repos/JungleCandy/Either/pulls{/number}","milestones_url":"https://api.github.com/repos/JungleCandy/Either/milestones{/number}","notifications_url":"https://api.github.com/repos/JungleCandy/Either/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JungleCandy/Either/labels{/name}","releases_url":"https://api.github.com/repos/JungleCandy/Either/releases{/id}","created_at":"2015-04-03T19:16:26Z","updated_at":"2015-04-05T11:57:15Z","pushed_at":"2015-04-05T12:39:29Z","git_url":"git://github.com/JungleCandy/Either.git","ssh_url":"git@github.com:JungleCandy/Either.git","clone_url":"https://github.com/JungleCandy/Either.git","svn_url":"https://github.com/JungleCandy/Either","homepage":null,"size":482,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"robrix:master","ref":"master","sha":"026d3471bca7c9573fdec46bab3d8f265d2ec001","user":{"login":"robrix","id":59671,"avatar_url":"https://avatars.githubusercontent.com/u/59671?v=3","gravatar_id":"","url":"https://api.github.com/users/robrix","html_url":"https://github.com/robrix","followers_url":"https://api.github.com/users/robrix/followers","following_url":"https://api.github.com/users/robrix/following{/other_user}","gists_url":"https://api.github.com/users/robrix/gists{/gist_id}","starred_url":"https://api.github.com/users/robrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robrix/subscriptions","organizations_url":"https://api.github.com/users/robrix/orgs","repos_url":"https://api.github.com/users/robrix/repos","events_url":"https://api.github.com/users/robrix/events{/privacy}","received_events_url":"https://api.github.com/users/robrix/received_events","type":"User","site_admin":true},"repo":{"id":27358798,"name":"Either","full_name":"robrix/Either","owner":{"login":"robrix","id":59671,"avatar_url":"https://avatars.githubusercontent.com/u/59671?v=3","gravatar_id":"","url":"https://api.github.com/users/robrix","html_url":"https://github.com/robrix","followers_url":"https://api.github.com/users/robrix/followers","following_url":"https://api.github.com/users/robrix/following{/other_user}","gists_url":"https://api.github.com/users/robrix/gists{/gist_id}","starred_url":"https://api.github.com/users/robrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robrix/subscriptions","organizations_url":"https://api.github.com/users/robrix/orgs","repos_url":"https://api.github.com/users/robrix/repos","events_url":"https://api.github.com/users/robrix/events{/privacy}","received_events_url":"https://api.github.com/users/robrix/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/robrix/Either","description":"Swift µframework of Either, which represents two alternatives.","fork":false,"url":"https://api.github.com/repos/robrix/Either","forks_url":"https://api.github.com/repos/robrix/Either/forks","keys_url":"https://api.github.com/repos/robrix/Either/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robrix/Either/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robrix/Either/teams","hooks_url":"https://api.github.com/repos/robrix/Either/hooks","issue_events_url":"https://api.github.com/repos/robrix/Either/issues/events{/number}","events_url":"https://api.github.com/repos/robrix/Either/events","assignees_url":"https://api.github.com/repos/robrix/Either/assignees{/user}","branches_url":"https://api.github.com/repos/robrix/Either/branches{/branch}","tags_url":"https://api.github.com/repos/robrix/Either/tags","blobs_url":"https://api.github.com/repos/robrix/Either/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robrix/Either/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robrix/Either/git/refs{/sha}","trees_url":"https://api.github.com/repos/robrix/Either/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robrix/Either/statuses/{sha}","languages_url":"https://api.github.com/repos/robrix/Either/languages","stargazers_url":"https://api.github.com/repos/robrix/Either/stargazers","contributors_url":"https://api.github.com/repos/robrix/Either/contributors","subscribers_url":"https://api.github.com/repos/robrix/Either/subscribers","subscription_url":"https://api.github.com/repos/robrix/Either/subscription","commits_url":"https://api.github.com/repos/robrix/Either/commits{/sha}","git_commits_url":"https://api.github.com/repos/robrix/Either/git/commits{/sha}","comments_url":"https://api.github.com/repos/robrix/Either/comments{/number}","issue_comment_url":"https://api.github.com/repos/robrix/Either/issues/comments{/number}","contents_url":"https://api.github.com/repos/robrix/Either/contents/{+path}","compare_url":"https://api.github.com/repos/robrix/Either/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robrix/Either/merges","archive_url":"https://api.github.com/repos/robrix/Either/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robrix/Either/downloads","issues_url":"https://api.github.com/repos/robrix/Either/issues{/number}","pulls_url":"https://api.github.com/repos/robrix/Either/pulls{/number}","milestones_url":"https://api.github.com/repos/robrix/Either/milestones{/number}","notifications_url":"https://api.github.com/repos/robrix/Either/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robrix/Either/labels{/name}","releases_url":"https://api.github.com/repos/robrix/Either/releases{/id}","created_at":"2014-12-01T02:20:44Z","updated_at":"2015-04-05T12:43:13Z","pushed_at":"2015-04-05T12:43:13Z","git_url":"git://github.com/robrix/Either.git","ssh_url":"git@github.com:robrix/Either.git","clone_url":"https://github.com/robrix/Either.git","svn_url":"https://github.com/robrix/Either","homepage":null,"size":482,"stargazers_count":32,"watchers_count":32,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/robrix/Either/pulls/25"},"html":{"href":"https://github.com/robrix/Either/pull/25"},"issue":{"href":"https://api.github.com/repos/robrix/Either/issues/25"},"comments":{"href":"https://api.github.com/repos/robrix/Either/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/robrix/Either/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/robrix/Either/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/robrix/Either/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/robrix/Either/statuses/b556c2d0e9e6c643affb4fa941fa8141e3b61003"}}}}