Dialyzer @type t with Structs (can you make subtypes?)

I can specify possible values for fields in a struct and associate them with a @type t.

But in the @spec for my function, I have to use syntax such as:
@type t :: %MyStruct{count: integer}
@spec my_function(%MyStruct{count: 0}) :: atom

I don’t see a syntax (or I’m missing it) to do something like:
@spec my_function(MyStruct.t{count: 0}) :: atom

Is there a way to define further limited subtypes based on MyStruct?

Thanks,
Scott S.

@type t() :: t(integer())
@type t(cnt) :: %MyStruct{count: cnt}

If you have many fields which you want to specify in various mixes, this can get really tedius though.

3 Likes