This commit is contained in:
crumbtoo
2023-11-07 15:28:46 -07:00
parent 3e96c838b6
commit cc12d74ca4
3 changed files with 15 additions and 11 deletions

View File

@@ -20,7 +20,7 @@ Listed in order of importance.
- [ ] Backend - [ ] Backend
- [ ] Core language - [ ] Core language
- [x] AST - [ ] AST
- [ ] Emitter - [ ] Emitter
- [ ] MSIL Codegen module - [ ] MSIL Codegen module
- [ ] Core language emitter - [ ] Core language emitter

View File

@@ -1,7 +1,5 @@
package rlp; package rlp;
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
import java.util.function.BiFunction;
/*------------------------------------------------------------------------------*/
public class Core public class Core
{ {
@@ -13,10 +11,11 @@ public class Core
public record TyAbs(Name n, Expr m) implements Expr {} public record TyAbs(Name n, Expr m) implements Expr {}
public record Var(Name n) implements Expr {} public record Var(Name n) implements Expr {}
sealed interface Ty permits TyVar, Forall, TyFunc {} sealed interface Ty permits VarTy, Forall, FuncTy, AppTy {}
public record TyVar(Name n) implements Ty {} public record VarTy(Name n) implements Ty {}
public record Forall(Name n, Ty t) implements Ty {} public record Forall(Name n, Ty m) implements Ty {}
public record TyFunc(Ty a, Ty b) 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 public final static class Name
{ {
@@ -74,9 +73,14 @@ public class Core
{ {
return switch(t) return switch(t)
{ {
case TyVar a -> a.n.s; case VarTy a ->
case Forall a -> ""; a.n.s;
case TyFunc a -> ""; 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);
}; };
} }

View File

@@ -12,7 +12,7 @@ class RLPC
new Core.App new Core.App
( new Core.Abs ( new Core.Abs
( new Core.Name("x") ( 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("x"))
) )
, new Core.Var(new Core.Name("y"))); , new Core.Var(new Core.Name("y")));