[Pitch] Enum Composition

I like it. However, given that an enum can have one of several values, and that the composition still could only have one of the combined values, maybe DatasourceError | ManagerError is a better spelling?

Also, could this be implemented using a type, maybe called Either, which could get compiler endowed syntactic sugar similar to how Optional is just a simple type with some ergonomic syntax. A | B could be sugar for Either<A, B> and it could compose, and switches over an Either type could automatically wrap your case labels in .left and .right cases accordingly?

3 Likes