4 ms·
Just define an Interface which includes the implementation of thisIsMySumTypeAsAnInterface() Then only types which implement that are in that Interface. There'
by stcredzero 7y ago
Just define an Interface which includes the implementation of thisIsMySumTypeAsAnInterface()
Then only types which implement that are in that Interface. There's your enum/sum type. Not ironclad, but safe enough to get things done.
- stouset 7y agoIt also doesn't actually accomplish what people are talking about using sum types for. There's also no language support for ensuring you've exhaustively matched every variant.