idk :3
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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")));
|
||||||
|
|||||||
Reference in New Issue
Block a user