diff --git a/README.md b/README.md index 35192e5..2d57293 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Listed in order of importance. - [ ] Backend - [ ] Core language - - [x] AST + - [ ] AST - [ ] Emitter - [ ] MSIL Codegen module - [ ] Core language emitter diff --git a/rlp/Core.java b/rlp/Core.java index 158176a..05bbaab 100644 --- a/rlp/Core.java +++ b/rlp/Core.java @@ -1,7 +1,5 @@ package rlp; /*------------------------------------------------------------------------------*/ -import java.util.function.BiFunction; -/*------------------------------------------------------------------------------*/ public class Core { @@ -13,10 +11,11 @@ public class Core public record TyAbs(Name n, Expr m) implements Expr {} public record Var(Name n) implements Expr {} - sealed interface Ty permits TyVar, Forall, TyFunc {} - public record TyVar(Name n) implements Ty {} - public record Forall(Name n, Ty t) implements Ty {} - public record TyFunc(Ty a, Ty b) implements Ty {} + sealed interface Ty permits VarTy, Forall, FuncTy, AppTy {} + public record VarTy(Name n) implements Ty {} + public record Forall(Name n, Ty m) implements Ty {} + public record FuncTy(Ty a, Ty b) implements Ty {} + public record AppTy(Ty f, Ty x) implements Ty {} public final static class Name { @@ -74,9 +73,14 @@ public class Core { return switch(t) { - case TyVar a -> a.n.s; - case Forall a -> ""; - case TyFunc a -> ""; + case VarTy a -> + a.n.s; + case Forall a -> + wrap(p, 0, "∀" + a.n.s + "." + showTyP(0, a.m)); + case FuncTy a -> + ""; + case AppTy a -> + showTyP(2, a.f) + " " + showTyP(2, a.x); }; } diff --git a/rlp/RLPC.java b/rlp/RLPC.java index a2db769..404aa99 100644 --- a/rlp/RLPC.java +++ b/rlp/RLPC.java @@ -12,7 +12,7 @@ class RLPC new Core.App ( new Core.Abs ( new Core.Name("x") - , new Core.TyVar(new Core.Name("α")) + , new Core.VarTy(new Core.Name("α")) , new Core.Var(new Core.Name("x")) ) , new Core.Var(new Core.Name("y")));