Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
unify: a problematic implement of conversion check of sigma type
Browse files Browse the repository at this point in the history
  • Loading branch information
HoshinoTented authored and ice1000 committed Mar 8, 2024
1 parent 9ddac17 commit 6b3e0c9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
15 changes: 11 additions & 4 deletions base/src/main/java/org/aya/tyck/unify/TermComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ case Pair(LamTerm(var lbody), LamTerm(var rbody)) -> state().dCtx().with(pi.para
case Pair(_, LamTerm rambda) -> compareLambda(rambda, lhs, pi);
default -> false;
};
case SigmaTerm(var components) -> {
components.forEachIndexed((i, iType) -> {
case SigmaTerm(var paramSeq) -> {
// We use view since we need to instantiate the remaining params after tyck some component.
var params = paramSeq.view();
var size = paramSeq.size();
for (var i = 0; i < size; ++ i) {
var l = ProjTerm.make(lhs, i);
var r = ProjTerm.make(rhs, i);
});
throw new UnsupportedOperationException("TODO: hoshino");
var param = params.getFirst();
if (! compare(l, r, param)) yield false;
params = params.drop(1).mapIndexed((j, term) ->
term.replace(j, l));
}
yield true;
}
default -> false;
};
Expand Down
14 changes: 14 additions & 0 deletions syntax/src/main/java/org/aya/syntax/ref/DeBruijnCtx.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.ref;

import kala.collection.immutable.ImmutableSeq;
import kala.collection.mutable.MutableList;
import org.aya.syntax.core.term.Term;
import org.aya.util.error.InternalException;
Expand Down Expand Up @@ -40,4 +41,17 @@ public void push(@NotNull Term type) {
if (ctx.isEmpty()) throw new InternalException("empty ctx");
return ctx.removeLast();
}

public @NotNull ImmutableSeq<Term> popMany(int how) {
if (how < 0) throw new InternalException(STR."Unable to pop \{how} elements without elements");

var acc = MutableList.<Term>create();

while (how > 0) {
-- how;
acc.append(pop());
}

return acc.toImmutableSeq();
}
}

0 comments on commit 6b3e0c9

Please sign in to comment.