{"action":"created","comment":{"url":"https://api.github.com/repos/antitypical/Result/pulls/comments/46418655","id":46418655,"diff_hunk":"@@ -64,6 +64,30 @@ public extension ResultType {\n \t}\n }\n \n+/// Protocol used to constrain a version of `map` for `transform`s that throw.\n+public protocol ErrorTypeConvertible: ErrorType {\n+\ttypealias ConvertibleType = Self\n+\tstatic func errorFromErrorType(error:ErrorType) -> ConvertibleType\n+}\n+\n+public extension ResultType where Error: ErrorTypeConvertible {\n+\n+\t/// Returns the result of applying `transform` to `Success`es’ values, or wrapping thrown errors.\n+\tpublic func map<U>(@noescape transform: Value throws -> U) -> Result<U, Error> {\n+\t\treturn flatMap { value in\n+\t\t\tdo {\n+\t\t\t\treturn .Success(try transform(value))\n+\t\t\t}\n+\t\t\tcatch {\n+\t\t\t\tguard let convertedError = Error.errorFromErrorType(error) as? Error else {\n+\t\t\t\t\tfatalError(\"Unable to convert error type '\\(error.dynamicType)' to type '\\(Error.self)'\")\n+\t\t\t\t}\n+\t\t\t\treturn .Failure(convertedError)","path":"Result/ResultType.swift","position":22,"original_position":22,"commit_id":"dee43500a19c83e9db96ccb9a8d95ffcea697dbb","original_commit_id":"1e277d881ad25598bf0446c71171172d58cd45cf","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":"Yeah, I don’t think this is precisely `map` _or_ `flatMap`.","created_at":"2015-12-02T14:19:28Z","updated_at":"2015-12-02T14:19:28Z","html_url":"https://github.com/antitypical/Result/pull/118#discussion_r46418655","pull_request_url":"https://api.github.com/repos/antitypical/Result/pulls/118","_links":{"self":{"href":"https://api.github.com/repos/antitypical/Result/pulls/comments/46418655"},"html":{"href":"https://github.com/antitypical/Result/pull/118#discussion_r46418655"},"pull_request":{"href":"https://api.github.com/repos/antitypical/Result/pulls/118"}}},"pull_request":{"url":"https://api.github.com/repos/antitypical/Result/pulls/118","id":49996413,"html_url":"https://github.com/antitypical/Result/pull/118","diff_url":"https://github.com/antitypical/Result/pull/118.diff","patch_url":"https://github.com/antitypical/Result/pull/118.patch","issue_url":"https://api.github.com/repos/antitypical/Result/issues/118","number":118,"state":"open","locked":false,"title":"Add a version of `map` that converts thrown errors to `Failure`s.","user":{"login":"bwhiteley","id":601312,"avatar_url":"https://avatars.githubusercontent.com/u/601312?v=3","gravatar_id":"","url":"https://api.github.com/users/bwhiteley","html_url":"https://github.com/bwhiteley","followers_url":"https://api.github.com/users/bwhiteley/followers","following_url":"https://api.github.com/users/bwhiteley/following{/other_user}","gists_url":"https://api.github.com/users/bwhiteley/gists{/gist_id}","starred_url":"https://api.github.com/users/bwhiteley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwhiteley/subscriptions","organizations_url":"https://api.github.com/users/bwhiteley/orgs","repos_url":"https://api.github.com/users/bwhiteley/repos","events_url":"https://api.github.com/users/bwhiteley/events{/privacy}","received_events_url":"https://api.github.com/users/bwhiteley/received_events","type":"User","site_admin":false},"body":"Add a variant of `map` that handles `transform`s that throw errors and converts errors to `Failure`s.\r\nThis `map` is constrained to `Result`s with `Error` types that can be constructed from arbitrary `ErrorType`s.\r\n","created_at":"2015-11-06T19:47:16Z","updated_at":"2015-12-02T14:19:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5000f0466dc59914ce86892cc808faf5bb24092","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/antitypical/Result/pulls/118/commits","review_comments_url":"https://api.github.com/repos/antitypical/Result/pulls/118/comments","review_comment_url":"https://api.github.com/repos/antitypical/Result/pulls/comments{/number}","comments_url":"https://api.github.com/repos/antitypical/Result/issues/118/comments","statuses_url":"https://api.github.com/repos/antitypical/Result/statuses/dee43500a19c83e9db96ccb9a8d95ffcea697dbb","head":{"label":"bwhiteley:tryMap","ref":"tryMap","sha":"dee43500a19c83e9db96ccb9a8d95ffcea697dbb","user":{"login":"bwhiteley","id":601312,"avatar_url":"https://avatars.githubusercontent.com/u/601312?v=3","gravatar_id":"","url":"https://api.github.com/users/bwhiteley","html_url":"https://github.com/bwhiteley","followers_url":"https://api.github.com/users/bwhiteley/followers","following_url":"https://api.github.com/users/bwhiteley/following{/other_user}","gists_url":"https://api.github.com/users/bwhiteley/gists{/gist_id}","starred_url":"https://api.github.com/users/bwhiteley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwhiteley/subscriptions","organizations_url":"https://api.github.com/users/bwhiteley/orgs","repos_url":"https://api.github.com/users/bwhiteley/repos","events_url":"https://api.github.com/users/bwhiteley/events{/privacy}","received_events_url":"https://api.github.com/users/bwhiteley/received_events","type":"User","site_admin":false},"repo":{"id":45476024,"name":"Result","full_name":"bwhiteley/Result","owner":{"login":"bwhiteley","id":601312,"avatar_url":"https://avatars.githubusercontent.com/u/601312?v=3","gravatar_id":"","url":"https://api.github.com/users/bwhiteley","html_url":"https://github.com/bwhiteley","followers_url":"https://api.github.com/users/bwhiteley/followers","following_url":"https://api.github.com/users/bwhiteley/following{/other_user}","gists_url":"https://api.github.com/users/bwhiteley/gists{/gist_id}","starred_url":"https://api.github.com/users/bwhiteley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwhiteley/subscriptions","organizations_url":"https://api.github.com/users/bwhiteley/orgs","repos_url":"https://api.github.com/users/bwhiteley/repos","events_url":"https://api.github.com/users/bwhiteley/events{/privacy}","received_events_url":"https://api.github.com/users/bwhiteley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bwhiteley/Result","description":"Swift type modelling the success/failure of arbitrary operations.","fork":true,"url":"https://api.github.com/repos/bwhiteley/Result","forks_url":"https://api.github.com/repos/bwhiteley/Result/forks","keys_url":"https://api.github.com/repos/bwhiteley/Result/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bwhiteley/Result/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bwhiteley/Result/teams","hooks_url":"https://api.github.com/repos/bwhiteley/Result/hooks","issue_events_url":"https://api.github.com/repos/bwhiteley/Result/issues/events{/number}","events_url":"https://api.github.com/repos/bwhiteley/Result/events","assignees_url":"https://api.github.com/repos/bwhiteley/Result/assignees{/user}","branches_url":"https://api.github.com/repos/bwhiteley/Result/branches{/branch}","tags_url":"https://api.github.com/repos/bwhiteley/Result/tags","blobs_url":"https://api.github.com/repos/bwhiteley/Result/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bwhiteley/Result/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bwhiteley/Result/git/refs{/sha}","trees_url":"https://api.github.com/repos/bwhiteley/Result/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bwhiteley/Result/statuses/{sha}","languages_url":"https://api.github.com/repos/bwhiteley/Result/languages","stargazers_url":"https://api.github.com/repos/bwhiteley/Result/stargazers","contributors_url":"https://api.github.com/repos/bwhiteley/Result/contributors","subscribers_url":"https://api.github.com/repos/bwhiteley/Result/subscribers","subscription_url":"https://api.github.com/repos/bwhiteley/Result/subscription","commits_url":"https://api.github.com/repos/bwhiteley/Result/commits{/sha}","git_commits_url":"https://api.github.com/repos/bwhiteley/Result/git/commits{/sha}","comments_url":"https://api.github.com/repos/bwhiteley/Result/comments{/number}","issue_comment_url":"https://api.github.com/repos/bwhiteley/Result/issues/comments{/number}","contents_url":"https://api.github.com/repos/bwhiteley/Result/contents/{+path}","compare_url":"https://api.github.com/repos/bwhiteley/Result/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bwhiteley/Result/merges","archive_url":"https://api.github.com/repos/bwhiteley/Result/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bwhiteley/Result/downloads","issues_url":"https://api.github.com/repos/bwhiteley/Result/issues{/number}","pulls_url":"https://api.github.com/repos/bwhiteley/Result/pulls{/number}","milestones_url":"https://api.github.com/repos/bwhiteley/Result/milestones{/number}","notifications_url":"https://api.github.com/repos/bwhiteley/Result/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bwhiteley/Result/labels{/name}","releases_url":"https://api.github.com/repos/bwhiteley/Result/releases{/id}","created_at":"2015-11-03T15:32:14Z","updated_at":"2015-11-03T15:32:15Z","pushed_at":"2015-12-02T01:09:18Z","git_url":"git://github.com/bwhiteley/Result.git","ssh_url":"git@github.com:bwhiteley/Result.git","clone_url":"https://github.com/bwhiteley/Result.git","svn_url":"https://github.com/bwhiteley/Result","homepage":null,"size":144,"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":"antitypical:master","ref":"master","sha":"4b4b709a0d89fd755acf2b1167785b455d48fb3d","user":{"login":"antitypical","id":6732310,"avatar_url":"https://avatars.githubusercontent.com/u/6732310?v=3","gravatar_id":"","url":"https://api.github.com/users/antitypical","html_url":"https://github.com/antitypical","followers_url":"https://api.github.com/users/antitypical/followers","following_url":"https://api.github.com/users/antitypical/following{/other_user}","gists_url":"https://api.github.com/users/antitypical/gists{/gist_id}","starred_url":"https://api.github.com/users/antitypical/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antitypical/subscriptions","organizations_url":"https://api.github.com/users/antitypical/orgs","repos_url":"https://api.github.com/users/antitypical/repos","events_url":"https://api.github.com/users/antitypical/events{/privacy}","received_events_url":"https://api.github.com/users/antitypical/received_events","type":"Organization","site_admin":false},"repo":{"id":31188467,"name":"Result","full_name":"antitypical/Result","owner":{"login":"antitypical","id":6732310,"avatar_url":"https://avatars.githubusercontent.com/u/6732310?v=3","gravatar_id":"","url":"https://api.github.com/users/antitypical","html_url":"https://github.com/antitypical","followers_url":"https://api.github.com/users/antitypical/followers","following_url":"https://api.github.com/users/antitypical/following{/other_user}","gists_url":"https://api.github.com/users/antitypical/gists{/gist_id}","starred_url":"https://api.github.com/users/antitypical/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antitypical/subscriptions","organizations_url":"https://api.github.com/users/antitypical/orgs","repos_url":"https://api.github.com/users/antitypical/repos","events_url":"https://api.github.com/users/antitypical/events{/privacy}","received_events_url":"https://api.github.com/users/antitypical/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/antitypical/Result","description":"Swift type modelling the success/failure of arbitrary operations.","fork":false,"url":"https://api.github.com/repos/antitypical/Result","forks_url":"https://api.github.com/repos/antitypical/Result/forks","keys_url":"https://api.github.com/repos/antitypical/Result/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antitypical/Result/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antitypical/Result/teams","hooks_url":"https://api.github.com/repos/antitypical/Result/hooks","issue_events_url":"https://api.github.com/repos/antitypical/Result/issues/events{/number}","events_url":"https://api.github.com/repos/antitypical/Result/events","assignees_url":"https://api.github.com/repos/antitypical/Result/assignees{/user}","branches_url":"https://api.github.com/repos/antitypical/Result/branches{/branch}","tags_url":"https://api.github.com/repos/antitypical/Result/tags","blobs_url":"https://api.github.com/repos/antitypical/Result/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antitypical/Result/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antitypical/Result/git/refs{/sha}","trees_url":"https://api.github.com/repos/antitypical/Result/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antitypical/Result/statuses/{sha}","languages_url":"https://api.github.com/repos/antitypical/Result/languages","stargazers_url":"https://api.github.com/repos/antitypical/Result/stargazers","contributors_url":"https://api.github.com/repos/antitypical/Result/contributors","subscribers_url":"https://api.github.com/repos/antitypical/Result/subscribers","subscription_url":"https://api.github.com/repos/antitypical/Result/subscription","commits_url":"https://api.github.com/repos/antitypical/Result/commits{/sha}","git_commits_url":"https://api.github.com/repos/antitypical/Result/git/commits{/sha}","comments_url":"https://api.github.com/repos/antitypical/Result/comments{/number}","issue_comment_url":"https://api.github.com/repos/antitypical/Result/issues/comments{/number}","contents_url":"https://api.github.com/repos/antitypical/Result/contents/{+path}","compare_url":"https://api.github.com/repos/antitypical/Result/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antitypical/Result/merges","archive_url":"https://api.github.com/repos/antitypical/Result/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antitypical/Result/downloads","issues_url":"https://api.github.com/repos/antitypical/Result/issues{/number}","pulls_url":"https://api.github.com/repos/antitypical/Result/pulls{/number}","milestones_url":"https://api.github.com/repos/antitypical/Result/milestones{/number}","notifications_url":"https://api.github.com/repos/antitypical/Result/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antitypical/Result/labels{/name}","releases_url":"https://api.github.com/repos/antitypical/Result/releases{/id}","created_at":"2015-02-23T00:41:05Z","updated_at":"2015-12-01T15:16:53Z","pushed_at":"2015-12-02T01:09:18Z","git_url":"git://github.com/antitypical/Result.git","ssh_url":"git@github.com:antitypical/Result.git","clone_url":"https://github.com/antitypical/Result.git","svn_url":"https://github.com/antitypical/Result","homepage":null,"size":254,"stargazers_count":571,"watchers_count":571,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":12,"forks":54,"open_issues":12,"watchers":571,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/antitypical/Result/pulls/118"},"html":{"href":"https://github.com/antitypical/Result/pull/118"},"issue":{"href":"https://api.github.com/repos/antitypical/Result/issues/118"},"comments":{"href":"https://api.github.com/repos/antitypical/Result/issues/118/comments"},"review_comments":{"href":"https://api.github.com/repos/antitypical/Result/pulls/118/comments"},"review_comment":{"href":"https://api.github.com/repos/antitypical/Result/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/antitypical/Result/pulls/118/commits"},"statuses":{"href":"https://api.github.com/repos/antitypical/Result/statuses/dee43500a19c83e9db96ccb9a8d95ffcea697dbb"}}}}