4 ms·
No, they can't. At least not in a type-safe way.
by akavi 7y ago
No, they can't. At least not in a type-safe way.
- stcredzero 7y agoJust 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.