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

Commit

Permalink
term: FnCall
Browse files Browse the repository at this point in the history
  • Loading branch information
HoshinoTented committed Jan 16, 2024
1 parent f06e263 commit ebeba8e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 5 deletions.
1 change: 1 addition & 0 deletions base/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
exports org.aya.syntax.core.term;
exports org.aya.syntax.ref;
exports org.aya.resolve.context;
exports org.aya.syntax.core.term.call;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.aya.syntax.core.def.DataDef;
import org.aya.syntax.core.def.FnDef;
import org.aya.syntax.core.def.TeleDef;
import org.aya.syntax.core.term.DataCall;
import org.aya.syntax.core.term.call.DataCall;
import org.aya.syntax.core.term.SortTerm;
import org.aya.syntax.core.term.Term;
import org.aya.syntax.ref.DefVar;
Expand Down
2 changes: 2 additions & 0 deletions base/src/main/java/org/aya/syntax/core/term/Formation.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.core.term;

import org.aya.syntax.core.term.call.DataCall;

/**
* Term formers, definitely.
* Note that {@link PrimCall} may also be term formers, but not necessarily.
Expand Down
2 changes: 2 additions & 0 deletions base/src/main/java/org/aya/syntax/core/term/StableWHNF.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.core.term;

import org.aya.syntax.core.term.call.DataCall;

/**
* Cubical-stable WHNF: those who will not change to other term formers
* after a substitution (this usually happens under face restrictions (aka cofibrations)).
Expand Down
1 change: 1 addition & 0 deletions base/src/main/java/org/aya/syntax/core/term/Term.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.aya.generic.AyaDocile;
import org.aya.pretty.doc.Doc;
import org.aya.syntax.core.pat.Pat;
import org.aya.syntax.core.term.call.Callable;
import org.aya.syntax.ref.LocalVar;
import org.aya.util.Arg;
import org.aya.util.error.SourcePos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.core.term;
package org.aya.syntax.core.term.call;

import kala.collection.immutable.ImmutableSeq;
import org.aya.syntax.concrete.stmt.decl.Decl;
import org.aya.syntax.concrete.stmt.decl.TeleDecl;
import org.aya.syntax.core.def.TeleDef;
import org.aya.syntax.core.term.AppTerm;
import org.aya.syntax.core.term.Term;
import org.aya.syntax.ref.AnyVar;
import org.aya.syntax.ref.DefVar;
import org.aya.util.Arg;
Expand All @@ -22,7 +24,7 @@ public sealed interface Callable extends Term permits Callable.Common {
/**
* Call to a {@link TeleDecl}.
*/
sealed interface Tele extends Common permits DataCall {
sealed interface Tele extends Common permits DataCall, FnCall {
@Override @NotNull DefVar<? extends TeleDef, ? extends TeleDecl<?>> ref();
int ulift();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.core.term;
package org.aya.syntax.core.term.call;

import kala.collection.immutable.ImmutableSeq;
import kala.function.IndexedFunction;
import org.aya.syntax.concrete.stmt.decl.TeleDecl;
import org.aya.syntax.core.def.DataDef;
import org.aya.syntax.core.term.Formation;
import org.aya.syntax.core.term.StableWHNF;
import org.aya.syntax.core.term.Term;
import org.aya.syntax.ref.DefVar;
import org.aya.util.Arg;
import org.jetbrains.annotations.NotNull;
Expand Down
27 changes: 27 additions & 0 deletions base/src/main/java/org/aya/syntax/core/term/call/FnCall.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.core.term.call;

import kala.collection.immutable.ImmutableSeq;
import kala.function.IndexedFunction;
import org.aya.syntax.concrete.stmt.decl.TeleDecl;
import org.aya.syntax.core.def.FnDef;
import org.aya.syntax.core.term.Term;
import org.aya.syntax.ref.DefVar;
import org.aya.util.Arg;
import org.jetbrains.annotations.NotNull;

public record FnCall(
@Override @NotNull DefVar<FnDef, TeleDecl.FnDecl> ref,
@Override int ulift,
@Override @NotNull ImmutableSeq<Arg<@NotNull Term>> args
) implements Callable.Tele {
public @NotNull FnCall update(@NotNull ImmutableSeq<Arg<Term>> args) {
return args.sameElements(args(), true) ? this : new FnCall(ref, ulift, args);
}

@Override
public @NotNull Term descent(@NotNull IndexedFunction<Term, Term> f) {
return update(args.map(x -> x.descent(t -> f.apply(0, t))));
}
}

0 comments on commit ebeba8e

Please sign in to comment.