|
|
|
|
|
by lmm
2961 days ago
|
|
> You shouldn't be able to use a type without giving all the necessary type parameters, so you can't form a union type with unbound type parameters in So inside the body of a generic method (or class) you can't form unions involving the method's type parameters? That works but makes them much less useful as a language feature - most language features work as normal within a generic method. > I'm not 100% sure how you can integrate sum types with a flow-typing system, perhaps with pattern matching? Whatever you do for union types should work, surely. Indeed it ought to be simpler since you have more information to work with - with a sum type if the thing is B then you know it's not A, whereas with a union type it's possible for the thing to be both A and B. |
|
And regarding sum types I was just thinking syntactically instead of in terms of the type system.