Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Apr 21, 2024
1 parent 438e502 commit 58850a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/langs/explicit-substitution/reduce/doAp.cic
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Mod } from "../mod/Mod.cic"
import { reduce } from "./reduce.cic"

export function doAp(mod: Mod, target: Exp, arg: Exp): Exp {
match (target) {
match target {
case Exp::Fn(name, ret) =>
reduce(mod, Exp::Let([new Binding(name, arg)], ret))

Expand Down
4 changes: 2 additions & 2 deletions docs/langs/explicit-substitution/reduce/reduce.cic
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { substitute } from "./substitute.cic"
// but it will always remove `Let`.

export function reduce(mod: Mod, exp: Exp): Exp {
match (exp) {
case Exp::Var(name) => match (modFind(mod, name)) {
match exp {
case Exp::Var(name) => match modFind(mod, name) {
case Maybe::Just(defintion) => exp
case Maybe::Nothing() => reduce(mod, defintion.exp)
}
Expand Down
10 changes: 5 additions & 5 deletions docs/langs/explicit-substitution/reduce/substitute.cic
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export function substitute(
bindings: List(Binding),
body: Exp,
): Exp {
match (body) {
case Exp::Var(name) => match (lookup(name, bindings)) {
case Maybe::Just(exp) => exp
case Maybe::Nothing() => body
}
match body {
case Exp::Var(name) => match lookup(name, bindings) {
case Maybe::Just(exp) => exp
case Maybe::Nothing() => body
}

case Exp::Fn(name, ret) => {
let freshName = freshen(name)
Expand Down

0 comments on commit 58850a5

Please sign in to comment.