All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aya.tyck.ctx.LocalLet Maven / Gradle / Ivy

The newest version!
// 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.tyck.ctx;

import kala.collection.mutable.MutableLinkedHashMap;
import kala.control.Option;
import org.aya.syntax.core.Jdg;
import org.aya.syntax.ref.LocalVar;
import org.aya.util.Scoped;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * A locally, lazy substitution
* Every substitution should be well-scoped, i.e., * {@link Jdg} can only refer to some free variable or elder lazy substitution. */ public record LocalLet( @Override @Nullable LocalLet parent, @NotNull MutableLinkedHashMap subst ) implements Scoped { public LocalLet() { this(null, MutableLinkedHashMap.of()); } @Override public @NotNull LocalLet self() { return this; } @Override public @NotNull LocalLet derive() { return new LocalLet(this, MutableLinkedHashMap.of()); } @Override public @NotNull Option getLocal(@NotNull LocalVar key) { return subst.getOption(key); } @Override public void putLocal(@NotNull LocalVar key, @NotNull Jdg value) { subst.put(key, value); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy