Typevariables - how about `struct MyType{T isa MyEnum} end`?

Hi there,

I am thinking about a good way to selfdocument type variables. My first attempt is using @enum, but it seems this is not really useful, as the different enum instances are values and no types and hence cannot be restricted as struct MyType{T <: MyEnum} end

I guess the best way is to define the types individually, but anyway I would like to bring the question whether a syntax support like struct MyType{T isa MyEnum} end would be benefitial for such cases?

The usual way of lifting values to the type domain is Val. You could write struct MyType{T <: Val{<:MyEnum}}.

1 Like