This can be done using the following syntax:
(::Type{MyType{T}}){T}() = MyType{T}(T[])
The thing in the first set of parentheses describes the called object. ::T means "type T", so this is the definition for calling an object of type Type{MyType{T}} , which means the object MyType{T} . The following {T} means that T is a parameter of this definition, and a value for it must be available to call this definition. So MyType{Int} consistent, but MyType not. From there, the syntax should be familiar.
This syntax is definitely a little weird and unintuitive, and we hope to improve it in a future version of the language, hopefully v0.6.
source share