3 ms·
You need flow typing when you do pattern matching on generalized abstract data type (GADT). Here is an example in Java sealed interface Foo<T> permits Impl
by _old_dude_ 5y ago
You need flow typing when you do pattern matching on generalized abstract data type (GADT).
Here is an example in Java
sealed interface Foo<T> permits Impl {} // union type
record Impl() implements Foo<String> {} // product type
<T> T m(Foo<T> foo) {
return switch(foo) {
case Impl impl -> "hello"; // flow typing T=String
};
}
- valenterry 5y agoBy that definition, many (maybe most) languages then already support flow typing.
- whimsicalism 5y agothat's not the same as what is defined in the article, and it is supported by plenty of languages