{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaData/Nulls.jl/issues/6","repository_url":"https://api.github.com/repos/JuliaData/Nulls.jl","labels_url":"https://api.github.com/repos/JuliaData/Nulls.jl/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/JuliaData/Nulls.jl/issues/6/comments","events_url":"https://api.github.com/repos/JuliaData/Nulls.jl/issues/6/events","html_url":"https://github.com/JuliaData/Nulls.jl/issues/6","id":228555758,"number":6,"title":"Union{T,Null} inference in structs","user":{"login":"davidanthoff","id":1036561,"avatar_url":"https://avatars3.githubusercontent.com/u/1036561?v=4","gravatar_id":"","url":"https://api.github.com/users/davidanthoff","html_url":"https://github.com/davidanthoff","followers_url":"https://api.github.com/users/davidanthoff/followers","following_url":"https://api.github.com/users/davidanthoff/following{/other_user}","gists_url":"https://api.github.com/users/davidanthoff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidanthoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidanthoff/subscriptions","organizations_url":"https://api.github.com/users/davidanthoff/orgs","repos_url":"https://api.github.com/users/davidanthoff/repos","events_url":"https://api.github.com/users/davidanthoff/events{/privacy}","received_events_url":"https://api.github.com/users/davidanthoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":32,"created_at":"2017-05-14T17:27:08Z","updated_at":"2017-09-20T14:56:28Z","closed_at":null,"author_association":"NONE","body":"Say we have a struct like this:\r\n````julia\r\nstruct Foo{T}\r\n    v::T\r\nend\r\n````\r\nAnd a function like this:\r\n````\r\nfunction bar(x)\r\n    x = rand() > 0.5 : 0. : null\r\n    return Foo(x)\r\nend\r\n````\r\nThen the return type of this is currently inferred as ``Union{Foo{Float64}, Foo{Nulls.Null}}``. This won't work for the whole [Query.jl](https://github.com/davidanthoff/Query.jl) design, I would need the inferred return type here to be ``Foo{Union{Float64,Null}}``.\r\n\r\nBut here is the twist: I'm not convinced that this would be the right thing to do in general, i.e. that changing the current julia behavior across the board to something that squares with the needs of Query.jl would be a good idea. Note that this is not an issue with the current approach taken in Query.jl where I use the ``DataValue`` type from the [DataValues.jl](https://github.com/davidanthoff/DataValues.jl) package to represent missing values."},"comment":{"url":"https://api.github.com/repos/JuliaData/Nulls.jl/issues/comments/330878266","html_url":"https://github.com/JuliaData/Nulls.jl/issues/6#issuecomment-330878266","issue_url":"https://api.github.com/repos/JuliaData/Nulls.jl/issues/6","id":330878266,"user":{"login":"JeffBezanson","id":744556,"avatar_url":"https://avatars0.githubusercontent.com/u/744556?v=4","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},"created_at":"2017-09-20T14:56:28Z","updated_at":"2017-09-20T14:56:28Z","author_association":"NONE","body":"I'm a bit stuck here on not understanding what `Foo` and `Bar` are in e.g. https://github.com/JuliaData/Nulls.jl/issues/6#issuecomment-301537155 . Are they user-defined types, or internal types in Query.jl? What do they mean?\r\n\r\nOne possibility is to use something like type promotion, where `Foo{T}` and `Foo{Null}` can be promoted to `Foo{Union{T,Null}}`.\r\n\r\nAnother possibility is to use some interface that tells you the declared type of a field. For example\r\n\r\n```\r\ni -> Foo{fieldtype(i, :a), fieldtype(i, :b)}(i.a, i.b)\r\n```\r\n\r\n`fieldtype` happens to already exist, but this could be a new overloadable function instead, with default definition\r\n\r\n```\r\nfieldtype(x, f) = typeof(getfield(x, f))\r\n```\r\n"}}
{"actor":{"display_login":"JeffBezanson"}}