{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/89550531","pull_request_review_id":10096434,"id":89550531,"diff_hunk":"@@ -247,3 +247,45 @@ function hash(x::Nullable, h::UInt)\n         return hash(x.value, h + nullablehash_seed)\n     end\n end\n+\n+# higher-order functions\n+\"\"\"\n+    filter(p, x::Nullable)\n+\n+Return null if either `x` is null or `p(get(x))` is false, and `x` otherwise.\n+\"\"\"\n+function filter{T}(p, x::Nullable{T})\n+    if isnull(x) || p(get(x))\n+        x\n+    else\n+        Nullable{T}()\n+    end\n+end\n+\n+\"\"\"\n+Return the given type if it is concrete, and `Union{}` otherwise.\n+\"\"\"\n+concretify{T}(::Type{T}) = isleaftype(T) ? T : Union{}\n+\n+\"\"\"\n+    map(f, x::Nullable)\n+\n+Return `f` applied to the value of `x` if it has one, as a `Nullable`. If `x`\n+is null, then return a null value of type `Nullable{S}`. `S` is guaranteed to\n+be either `Union{}` or a concrete type. Whichever of these is chosen is an\n+implementation detail, but typically the choice that maximizes performance\n+would be used. If `x` has a value, then the return type is guaranteed to be of\n+type `Nullable{typeof(f(x))}`.\n+\"\"\"\n+function map{T}(f, x::Nullable{T})\n+    S = promote_op(f, T)\n+    if isleaftype(S) && null_safe_op(f, T)\n+        Nullable{S}(f(get(x)), isnull(x))","path":"base/nullable.jl","position":37,"original_position":37,"commit_id":"876d56e932c80d302a7f40f1af1ead1ad876a63b","original_commit_id":"876d56e932c80d302a7f40f1af1ead1ad876a63b","user":{"login":"TotalVerb","id":12903942,"avatar_url":"https://avatars.githubusercontent.com/u/12903942?v=3","gravatar_id":"","url":"https://api.github.com/users/TotalVerb","html_url":"https://github.com/TotalVerb","followers_url":"https://api.github.com/users/TotalVerb/followers","following_url":"https://api.github.com/users/TotalVerb/following{/other_user}","gists_url":"https://api.github.com/users/TotalVerb/gists{/gist_id}","starred_url":"https://api.github.com/users/TotalVerb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TotalVerb/subscriptions","organizations_url":"https://api.github.com/users/TotalVerb/orgs","repos_url":"https://api.github.com/users/TotalVerb/repos","events_url":"https://api.github.com/users/TotalVerb/events{/privacy}","received_events_url":"https://api.github.com/users/TotalVerb/received_events","type":"User","site_admin":false},"body":"Apparently this wasn't caught by the tests. I guess we need to actually define `null_safe_op` on one-argument functions?","created_at":"2016-11-24T22:46:52Z","updated_at":"2016-11-24T22:46:52Z","html_url":"https://github.com/JuliaLang/julia/pull/16961#discussion_r89550531","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/16961","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/89550531"},"html":{"href":"https://github.com/JuliaLang/julia/pull/16961#discussion_r89550531"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/16961"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/16961","id":74023137,"html_url":"https://github.com/JuliaLang/julia/pull/16961","diff_url":"https://github.com/JuliaLang/julia/pull/16961.diff","patch_url":"https://github.com/JuliaLang/julia/pull/16961.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/16961","number":16961,"state":"open","locked":false,"title":"RFC: Nullables as collections","user":{"login":"TotalVerb","id":12903942,"avatar_url":"https://avatars.githubusercontent.com/u/12903942?v=3","gravatar_id":"","url":"https://api.github.com/users/TotalVerb","html_url":"https://github.com/TotalVerb","followers_url":"https://api.github.com/users/TotalVerb/followers","following_url":"https://api.github.com/users/TotalVerb/following{/other_user}","gists_url":"https://api.github.com/users/TotalVerb/gists{/gist_id}","starred_url":"https://api.github.com/users/TotalVerb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TotalVerb/subscriptions","organizations_url":"https://api.github.com/users/TotalVerb/orgs","repos_url":"https://api.github.com/users/TotalVerb/repos","events_url":"https://api.github.com/users/TotalVerb/events{/privacy}","received_events_url":"https://api.github.com/users/TotalVerb/received_events","type":"User","site_admin":false},"body":"Migrated from https://github.com/JuliaStats/NullableArrays.jl/pull/115, closes #16889.\n\nQuick tour of the PR:\n- `getindex`\n- Scala-style map and filter. I did not implement Scala's fold semantics, because I consider that to be a mistake.\n- Since map is not type-stable, I also implemented broadcast as a type-stable map, with identical semantics to the version for arrays. broadcast also preserves the broadcasting capability of the version for arrays.\n\nPerformance is good (for single-argument map and for up to two arguments broadcast) but not perfect, as there are branches that could be avoided by doing tricks that apply only to certain bitstypes. Aside from that, there are not really any unnecessary operations.\n\nAs discussed in the original thread, one-argument `get` is being kept. For consistency, it might be useful to define two-argument `get` without default argument for array types.\n\ncc: @nalimilan @johnmyleswhite @hayd @vchuravy \n","created_at":"2016-06-16T05:12:29Z","updated_at":"2016-11-24T22:46:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9120a0bb66e724f25909d0c919aa46c4d2d93542","assignee":{"login":"johnmyleswhite","id":22064,"avatar_url":"https://avatars.githubusercontent.com/u/22064?v=3","gravatar_id":"","url":"https://api.github.com/users/johnmyleswhite","html_url":"https://github.com/johnmyleswhite","followers_url":"https://api.github.com/users/johnmyleswhite/followers","following_url":"https://api.github.com/users/johnmyleswhite/following{/other_user}","gists_url":"https://api.github.com/users/johnmyleswhite/gists{/gist_id}","starred_url":"https://api.github.com/users/johnmyleswhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnmyleswhite/subscriptions","organizations_url":"https://api.github.com/users/johnmyleswhite/orgs","repos_url":"https://api.github.com/users/johnmyleswhite/repos","events_url":"https://api.github.com/users/johnmyleswhite/events{/privacy}","received_events_url":"https://api.github.com/users/johnmyleswhite/received_events","type":"User","site_admin":false},"assignees":[{"login":"johnmyleswhite","id":22064,"avatar_url":"https://avatars.githubusercontent.com/u/22064?v=3","gravatar_id":"","url":"https://api.github.com/users/johnmyleswhite","html_url":"https://github.com/johnmyleswhite","followers_url":"https://api.github.com/users/johnmyleswhite/followers","following_url":"https://api.github.com/users/johnmyleswhite/following{/other_user}","gists_url":"https://api.github.com/users/johnmyleswhite/gists{/gist_id}","starred_url":"https://api.github.com/users/johnmyleswhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnmyleswhite/subscriptions","organizations_url":"https://api.github.com/users/johnmyleswhite/orgs","repos_url":"https://api.github.com/users/johnmyleswhite/repos","events_url":"https://api.github.com/users/johnmyleswhite/events{/privacy}","received_events_url":"https://api.github.com/users/johnmyleswhite/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/JuliaLang/julia/milestones/20","html_url":"https://github.com/JuliaLang/julia/milestones/0.6.0","labels_url":"https://api.github.com/repos/JuliaLang/julia/milestones/20/labels","id":1298021,"number":20,"title":"0.6.0","description":"","creator":{"login":"JeffBezanson","id":744556,"avatar_url":"https://avatars.githubusercontent.com/u/744556?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffBezanson","html_url":"https://github.com/JeffBezanson","followers_url":"https://api.github.com/users/JeffBezanson/followers","following_url":"https://api.github.com/users/JeffBezanson/following{/other_user}","gists_url":"https://api.github.com/users/JeffBezanson/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffBezanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffBezanson/subscriptions","organizations_url":"https://api.github.com/users/JeffBezanson/orgs","repos_url":"https://api.github.com/users/JeffBezanson/repos","events_url":"https://api.github.com/users/JeffBezanson/events{/privacy}","received_events_url":"https://api.github.com/users/JeffBezanson/received_events","type":"User","site_admin":false},"open_issues":168,"closed_issues":59,"state":"open","created_at":"2015-09-09T16:35:16Z","updated_at":"2016-11-21T09:34:38Z","due_on":"2017-01-31T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/16961/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/16961/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/16961/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/876d56e932c80d302a7f40f1af1ead1ad876a63b","head":{"label":"TotalVerb:fw/nullables-as-collections","ref":"fw/nullables-as-collections","sha":"876d56e932c80d302a7f40f1af1ead1ad876a63b","user":{"login":"TotalVerb","id":12903942,"avatar_url":"https://avatars.githubusercontent.com/u/12903942?v=3","gravatar_id":"","url":"https://api.github.com/users/TotalVerb","html_url":"https://github.com/TotalVerb","followers_url":"https://api.github.com/users/TotalVerb/followers","following_url":"https://api.github.com/users/TotalVerb/following{/other_user}","gists_url":"https://api.github.com/users/TotalVerb/gists{/gist_id}","starred_url":"https://api.github.com/users/TotalVerb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TotalVerb/subscriptions","organizations_url":"https://api.github.com/users/TotalVerb/orgs","repos_url":"https://api.github.com/users/TotalVerb/repos","events_url":"https://api.github.com/users/TotalVerb/events{/privacy}","received_events_url":"https://api.github.com/users/TotalVerb/received_events","type":"User","site_admin":false},"repo":{"id":56201182,"name":"julia","full_name":"TotalVerb/julia","owner":{"login":"TotalVerb","id":12903942,"avatar_url":"https://avatars.githubusercontent.com/u/12903942?v=3","gravatar_id":"","url":"https://api.github.com/users/TotalVerb","html_url":"https://github.com/TotalVerb","followers_url":"https://api.github.com/users/TotalVerb/followers","following_url":"https://api.github.com/users/TotalVerb/following{/other_user}","gists_url":"https://api.github.com/users/TotalVerb/gists{/gist_id}","starred_url":"https://api.github.com/users/TotalVerb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TotalVerb/subscriptions","organizations_url":"https://api.github.com/users/TotalVerb/orgs","repos_url":"https://api.github.com/users/TotalVerb/repos","events_url":"https://api.github.com/users/TotalVerb/events{/privacy}","received_events_url":"https://api.github.com/users/TotalVerb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TotalVerb/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/TotalVerb/julia","forks_url":"https://api.github.com/repos/TotalVerb/julia/forks","keys_url":"https://api.github.com/repos/TotalVerb/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TotalVerb/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TotalVerb/julia/teams","hooks_url":"https://api.github.com/repos/TotalVerb/julia/hooks","issue_events_url":"https://api.github.com/repos/TotalVerb/julia/issues/events{/number}","events_url":"https://api.github.com/repos/TotalVerb/julia/events","assignees_url":"https://api.github.com/repos/TotalVerb/julia/assignees{/user}","branches_url":"https://api.github.com/repos/TotalVerb/julia/branches{/branch}","tags_url":"https://api.github.com/repos/TotalVerb/julia/tags","blobs_url":"https://api.github.com/repos/TotalVerb/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TotalVerb/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TotalVerb/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/TotalVerb/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TotalVerb/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/TotalVerb/julia/languages","stargazers_url":"https://api.github.com/repos/TotalVerb/julia/stargazers","contributors_url":"https://api.github.com/repos/TotalVerb/julia/contributors","subscribers_url":"https://api.github.com/repos/TotalVerb/julia/subscribers","subscription_url":"https://api.github.com/repos/TotalVerb/julia/subscription","commits_url":"https://api.github.com/repos/TotalVerb/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/TotalVerb/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/TotalVerb/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/TotalVerb/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/TotalVerb/julia/contents/{+path}","compare_url":"https://api.github.com/repos/TotalVerb/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TotalVerb/julia/merges","archive_url":"https://api.github.com/repos/TotalVerb/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TotalVerb/julia/downloads","issues_url":"https://api.github.com/repos/TotalVerb/julia/issues{/number}","pulls_url":"https://api.github.com/repos/TotalVerb/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/TotalVerb/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/TotalVerb/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TotalVerb/julia/labels{/name}","releases_url":"https://api.github.com/repos/TotalVerb/julia/releases{/id}","deployments_url":"https://api.github.com/repos/TotalVerb/julia/deployments","created_at":"2016-04-14T02:29:35Z","updated_at":"2016-04-14T02:29:42Z","pushed_at":"2016-11-23T22:25:20Z","git_url":"git://github.com/TotalVerb/julia.git","ssh_url":"git@github.com:TotalVerb/julia.git","clone_url":"https://github.com/TotalVerb/julia.git","svn_url":"https://github.com/TotalVerb/julia","homepage":"http://julialang.org/","size":100526,"stargazers_count":0,"watchers_count":0,"language":"Julia","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":"JuliaLang:master","ref":"master","sha":"3daa183c909211e132399bdfe1417b51437d5b3b","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaLang/julia/deployments","created_at":"2011-04-21T07:01:50Z","updated_at":"2016-11-24T16:36:41Z","pushed_at":"2016-11-24T22:35:24Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":431604,"stargazers_count":7839,"watchers_count":7839,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1841,"mirror_url":null,"open_issues_count":2200,"forks":1841,"open_issues":2200,"watchers":7839,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/16961"},"html":{"href":"https://github.com/JuliaLang/julia/pull/16961"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/16961"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/16961/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/16961/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/16961/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/876d56e932c80d302a7f40f1af1ead1ad876a63b"}}}}
{"actor":{"display_login":"TotalVerb"}}