Thanks for the tip regarding apiworkbench, that's quite a nice implementation. (Too bad they don't have a vim plugin.) It seems that recursive data types are currently not supported, as this simplified example shows:
T: boolean | integer
U: T | string
This fails with the following error:
Extending from types extending union types is not allowed
I double-checked with the spec. The section Inheritance Restrictions mentions:
You cannot inherit from types extending union types ( ex: you cannot extend from
Pet = Dog | Cat )
Even though composition has nothing to with inheritance, it appears the example given conveys that composition of union types is not supported. This should be made clearer in the spec, and not convoluted with inheritance.
My next question is: why? In order to design composable data types, one naturally aggregates them into higher-level abstractions. Without composition, data types will remain of limited use with a few basic types and do not scale. Therefore, I advocate to remove this restriction from union types.