diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-09-30 11:22:24 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-09-30 11:22:24 +0100 |
| commit | 6d18d2156ae4063eee04ca467727e0ec0c4404cc (patch) | |
| tree | ca2da4b887cfe221247621670a010eee1ad18a4a /src/main/java | |
| parent | 107ce1646e24b0d30f7fc42e831a7e5f03daecc3 (diff) | |
Add SumType
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/types/SumType.java | 11 | ||||
| -rw-r--r-- | src/main/java/org/shedlang/compiler/types/Type.java | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/org/shedlang/compiler/types/SumType.java b/src/main/java/org/shedlang/compiler/types/SumType.java new file mode 100644 index 00000000..8c293fca --- /dev/null +++ b/src/main/java/org/shedlang/compiler/types/SumType.java @@ -0,0 +1,11 @@ +package org.shedlang.compiler.types; + +/** + * A discriminated union of several different types. + */ +public record SumType(NamespaceName namespaceName, String name) implements Type { + @Override + public String describe() { + return namespaceName.toString() + "." + name; + } +} diff --git a/src/main/java/org/shedlang/compiler/types/Type.java b/src/main/java/org/shedlang/compiler/types/Type.java index b88cf42b..a1de4068 100644 --- a/src/main/java/org/shedlang/compiler/types/Type.java +++ b/src/main/java/org/shedlang/compiler/types/Type.java @@ -6,5 +6,5 @@ package org.shedlang.compiler.types; * found through auxiliary data. */ public sealed interface Type extends TypeLevelValue - permits BoolType, BottomType, FunctionType, IntType, NamespaceType, StringType, StructType, TopType, TupleType, TypeLevelValueType, UnitType { + permits BoolType, BottomType, FunctionType, IntType, NamespaceType, StringType, StructType, SumType, TopType, TupleType, TypeLevelValueType, UnitType { } |
