[julia-users] Re: Nullable parametric types

2015-07-21 Thread Darwin Darakananda
Thanks for the responses!  I wasn't not sure how I could use typealiases to 
deal with this, so I went with the macro route and ended up with 
https://gist.github.com/darwindarak/0eb5e53c21c896392938.  It converts the 
functions/type declarations into the parametric form suggested by Mauro.

On Tuesday, July 21, 2015 at 2:50:16 PM UTC-7, David Gold wrote:

 Or use typealiases?

 On Tuesday, July 21, 2015 at 4:48:31 PM UTC-4, David Gold wrote:

 My instinct is to write a macro.

 On Tuesday, July 21, 2015 at 4:37:03 PM UTC-4, Darwin Darakananda wrote:

 Hi all,

 I'm in the process of replacing my Union{Nothing, T} annotations to 
 Nullable{T}, but I'm getting stuck when T is a parametric type.  For 
 example, replacing the function

 function myfunc(v::Union{Nothing, Vector})
 ...
 end

 with

 function myfunc(v::Nullable{Vector})
 ...
 end

 makes it completely uncallable since any vector I pass in comes with an 
 eltype parameter and Julia's type parameters are invariant.  For functions 
 or types that only have a couple Nullable types, I can do something like

 function myfunc{T}(v::Nullable{Vector{T}})
 ...
 end

 type MyType{T}
v::Nullable{Vector{T}
 end

 but that gets very ugly when you have a large number of nullable types. 
  Does anyone know of a cleaner way to do this?

 Thanks,

 Darwin



[julia-users] Re: Nullable parametric types

2015-07-21 Thread David Gold
Or use typealiases?

On Tuesday, July 21, 2015 at 4:48:31 PM UTC-4, David Gold wrote:

 My instinct is to write a macro.

 On Tuesday, July 21, 2015 at 4:37:03 PM UTC-4, Darwin Darakananda wrote:

 Hi all,

 I'm in the process of replacing my Union{Nothing, T} annotations to 
 Nullable{T}, but I'm getting stuck when T is a parametric type.  For 
 example, replacing the function

 function myfunc(v::Union{Nothing, Vector})
 ...
 end

 with

 function myfunc(v::Nullable{Vector})
 ...
 end

 makes it completely uncallable since any vector I pass in comes with an 
 eltype parameter and Julia's type parameters are invariant.  For functions 
 or types that only have a couple Nullable types, I can do something like

 function myfunc{T}(v::Nullable{Vector{T}})
 ...
 end

 type MyType{T}
v::Nullable{Vector{T}
 end

 but that gets very ugly when you have a large number of nullable types. 
  Does anyone know of a cleaner way to do this?

 Thanks,

 Darwin



[julia-users] Re: Nullable parametric types

2015-07-21 Thread David Gold
My instinct is to write a macro.

On Tuesday, July 21, 2015 at 4:37:03 PM UTC-4, Darwin Darakananda wrote:

 Hi all,

 I'm in the process of replacing my Union{Nothing, T} annotations to 
 Nullable{T}, but I'm getting stuck when T is a parametric type.  For 
 example, replacing the function

 function myfunc(v::Union{Nothing, Vector})
 ...
 end

 with

 function myfunc(v::Nullable{Vector})
 ...
 end

 makes it completely uncallable since any vector I pass in comes with an 
 eltype parameter and Julia's type parameters are invariant.  For functions 
 or types that only have a couple Nullable types, I can do something like

 function myfunc{T}(v::Nullable{Vector{T}})
 ...
 end

 type MyType{T}
v::Nullable{Vector{T}
 end

 but that gets very ugly when you have a large number of nullable types. 
  Does anyone know of a cleaner way to do this?

 Thanks,

 Darwin