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

Commit

Permalink
normalize: first step, add β-reductions
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Mar 9, 2024
1 parent 54e1623 commit 56606db
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions base/src/main/java/org/aya/normalize/Normalizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.normalize;

import kala.collection.immutable.ImmutableSet;
import org.aya.syntax.core.term.AppTerm;
import org.aya.syntax.core.term.ProjTerm;
import org.aya.syntax.core.term.StableWHNF;
import org.aya.syntax.core.term.Term;
import org.aya.syntax.ref.AnyVar;
import org.aya.tyck.TyckState;
import org.jetbrains.annotations.NotNull;

public record Normalizer(@NotNull TyckState state) {
/**
* Unlike in pre-v0.30 Aya, we use only one normalizer, only doing head reduction,
* and we merge conservative normalizer and the whnf normalizer.
*/
public record Normalizer(@NotNull TyckState state, @NotNull ImmutableSet<AnyVar> opaque) {
public Normalizer(@NotNull TyckState state) {
this(state, ImmutableSet.empty());
}

public @NotNull Term whnf(@NotNull Term term) {
// TODO
return term;
return switch (term) {
case StableWHNF whnf -> whnf;
case AppTerm app -> AppTerm.make(app);
case ProjTerm proj -> ProjTerm.make(proj);
// TODO: handle other cases
case Term _ -> term;
};
}
}

0 comments on commit 56606db

Please sign in to comment.