diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-02-09 17:12:36 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-02-09 17:12:36 +0000 |
| commit | 09dcc2a2c64eb2544d810bbc586241346130d258 (patch) | |
| tree | ae1bd5a3da237b5bf8cf648c1abdd289ed6e87d1 /src/main/java/org/shedlang/compiler/ast | |
| parent | 8cab12eaca01f9778530f066cbc77d1c72adbd19 (diff) | |
Parse type-level params for function type
Diffstat (limited to 'src/main/java/org/shedlang/compiler/ast')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionTypeNode.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionTypeNode.java b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionTypeNode.java index b4a465b3..c1b7ad3d 100644 --- a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionTypeNode.java +++ b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionTypeNode.java @@ -5,9 +5,11 @@ import org.shedlang.compiler.sources.Source; import org.shedlang.compiler.sources.Sources; import org.shedlang.compiler.util.P; +import java.util.List; import java.util.Optional; public record UntypedFunctionTypeNode( + Optional<List<UntypedTypeLevelParamNode>> typeLevelParams, UntypedFunctionTypeParamsNode params, Optional<UntypedTypeLevelExpressionNode> effect, UntypedTypeLevelExpressionNode returnType, @@ -15,6 +17,7 @@ public record UntypedFunctionTypeNode( ) implements UntypedTypeLevelExpressionNode { public static Builder builder() { return new Builder( + Optional.empty(), P.vector(), P.vector(), Optional.empty(), @@ -23,6 +26,7 @@ public record UntypedFunctionTypeNode( } public record Builder( + Optional<List<UntypedTypeLevelParamNode>> typeLevelParams, PVector<UntypedTypeLevelExpressionNode> positionalParams, PVector<UntypedFunctionTypeNamedParamNode> namedParams, Optional<UntypedTypeLevelExpressionNode> effect, @@ -30,6 +34,7 @@ public record UntypedFunctionTypeNode( ) { public UntypedFunctionTypeNode build() { return new UntypedFunctionTypeNode( + this.typeLevelParams, new UntypedFunctionTypeParamsNode(this.positionalParams, this.namedParams, Sources.NULL), this.effect, this.returnType, @@ -37,8 +42,19 @@ public record UntypedFunctionTypeNode( ); } + public Builder withTypeLevelParams(List<UntypedTypeLevelParamNode> typeLevelParams) { + return new Builder( + Optional.of(typeLevelParams), + this.positionalParams, + this.namedParams, + this.effect, + this.returnType + ); + } + public Builder addPositionalParam(UntypedTypeLevelExpressionNode param) { return new Builder( + this.typeLevelParams, this.positionalParams.plus(param), this.namedParams, this.effect, @@ -48,6 +64,7 @@ public record UntypedFunctionTypeNode( public Builder addNamedParam(String name, UntypedTypeLevelExpressionNode type) { return new Builder( + this.typeLevelParams, this.positionalParams, this.namedParams.plus(new UntypedFunctionTypeNamedParamNode(name, type, Sources.NULL)), this.effect, @@ -57,6 +74,7 @@ public record UntypedFunctionTypeNode( public Builder withEffect(UntypedTypeLevelExpressionNode effect) { return new Builder( + this.typeLevelParams, this.positionalParams, this.namedParams, Optional.of(effect), @@ -66,6 +84,7 @@ public record UntypedFunctionTypeNode( public Builder withReturnType(UntypedTypeLevelExpressionNode returnType) { return new Builder( + this.typeLevelParams, this.positionalParams, this.namedParams, this.effect, |
