You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Gypsum, it should be possible for a value to have a type that is a union of two or more types. For example:
class Foo
class Bar
def f(b: boolean): Foo | Bar = if (b) Foo() else Bar()
The type Foo | Bar is a union between Foo and Bar. This would be a subtype of both Foo and Bar, and for an instance of this type, it should be possible to call methods or access fields that are found in both types (those inherited from any common base class or trait).
This will be useful for exception handling (Java has something like this) and pattern matching in general. It is necessary for Type.lub to be properly implemented for traits.
Intersection types may also be useful, but I'm not sure when they would be used.
The text was updated successfully, but these errors were encountered:
In Gypsum, it should be possible for a value to have a type that is a union of two or more types. For example:
The type
Foo | Bar
is a union betweenFoo
andBar
. This would be a subtype of bothFoo
andBar
, and for an instance of this type, it should be possible to call methods or access fields that are found in both types (those inherited from any common base class or trait).This will be useful for exception handling (Java has something like this) and pattern matching in general. It is necessary for
Type.lub
to be properly implemented for traits.Intersection types may also be useful, but I'm not sure when they would be used.
The text was updated successfully, but these errors were encountered: